I am trying to create a live streaming camera with my Raspberry Pi and the Pi Camera module. I have chosen to create it with Flask so that I can use the Python API for it. Though when I run this script:
from flask import *
from picamera import PiCamera
app = Flask(__name__)
camera = PiCamera()
@app.route("/")
def index():
return render_template("index.html")
@app.route("/image.jpg")
def getImage():
camera.capture("./templates/image.jpg")
return send_file("./templates/image.jpg")
@app.route("/script.js")
def getTheScript():
return render_template("script.js")
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")
I get the following error:
mmal: mmal_vc_port_enable: failed to enable port vc.null_sink:in:0(OPQV): ENOSPC
mmal: mmal_port_enable: failed to enable connected port (vc.null_sink:in:0(OPQV))0x131e7b0 (ENOSPC)
mmal: mmal_connection_enable: output port couldn't be enabled
Traceback (most recent call last):
File "/home/pi/Desktop/camera_flask/app.py", line 6, in <module>
camera = PiCamera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 417, in __init__
self._init_preview()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 496, in _init_preview
self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
File "/usr/lib/python3/dist-packages/picamera/renderers.py", line 512, in __init__
self.renderer.connect(source)
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 1465, in connect
self._connection = MMALConnection(source, self.inputs[0])
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 1278, in __init__
prefix="Failed to enable connection")
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 157, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources (other than memory)
My first assumption based on the Failed to enable connection: Out of resources (other than memory)
part is that the pi was was not receiving enough power. So I got a 5V - 2.5A micro USB power adapter instead of the 5.1V - 1A adapter that I was using and it still shows this error.
Hope you can help
~ Iwotastic