I'm running an HTTP server written in python on my rasberry pi. The server takes images using a pi v2 camera module.
I have set crontab to auto start my script 30 seconds past boot.
The system works as expected as long as there is a screen connected via HDMI to the pi, and I get my 1920x1080 array of RGB data. However, booting the pi with the screen disconnected yields a totally unexpected output from the server and we get a fraction of the data when sending requests to the server.
Here is the server code:
class myHandler(BaseHTTPRequestHandler):
camera = RaspiCam()
#Handler for the GET requests
def do_GET(self):
img = self.camera.capture()
data = img.tostring()
self.send_response(200)
self.end_headers()
self.wfile.write(data)
return
PORT_NUMBER = int(sys.argv[1])
server = HTTPServer(('', PORT_NUMBER), myHandler)
server.serve_forever()
I came up with a solution to the problem. The default resolution in the picamera API is based on the resolution of the display. Which means that when the display was connected the resolution was 1920x1080 and with a disconnected display it was 720x480. This caused a problem when receiving the image since the receiver expected an image with the resolution 1920x1080. The solution was of course to set the resolution when instantiating the picamera object.