I have a probleme to display an image captured from picamera to a Apache 2 page :
In an index page (index.py) I can display a JPG image from a file.
But as soon as I want to display a JPG image from a capture with picamera, I have an error :
[error] [client 192.168.1.71] malformed header from script. Bad header=* failed to open vchiq instanc: index.py (from error.log file)
If someone has an idea of the error(s) made, thank you for your help.
Here is the index file:
Code: Select all
#!/usr/bin/env python
import cgi
import cgitb
cgitb.enable()
import sys
import time
import io
import aide2
a=aide2.lecture()
sys.stdout.write("Content-type: image/jpeg\n\n")
sys.stdout.write(a)Code: Select all
#!/usr/bin/env python
import sys
import time
import io
def lecture():
# image read
fichier=io.BytesIO()
fichier=open("Impact2.jpg","rb")
objet=fichier.read()
fichier.close()
return objet
Code: Select all
#!/usr/bin/env python
import sys
import time
import io
import picamera
def lecture():
# image capture
my_stream=io.BytesIO()
camera=picamera.PiCamera()
camera.resolution=(640, 480)
camera.capture(my_stream,format='jpeg')
my_stream.seek(0)
objet=my_stream.read()
camera.close()
return objet