4

When running a program on the Raspberry Pi Zero W, which involved the RPi Camera, I encountered an issue. This was based on the Joy Detector Demo, from the AIY Kit. Normally, it would change LED colours and make noised based on camera facial input (emotions), but I also added a part which would stream the extent of joy to ThingSpeak.

The expected output was for the program to run, using the camera , instead the following message appeared:

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))0xdd2800 (ENOSPC)
mmal: mmal_connection_enable: output port couldn't be enabled
ERROR:__main__:Exception while running joy demo.
Traceback (most recent call last):
  File "/home/pi/AIY-projects-python/src/examples/vision/joy/joy_detection_demo.py", line 383, in main
    args.enable_streaming, args.streaming_bitrate, args.mdns_name)
  File "/home/pi/AIY-projects-python/src/examples/vision/joy/joy_detection_demo.py", line 307, in joy_detector
    camera = stack.enter_context(PiCamera(sensor_mode=4, resolution=(820, 616)))
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 433, in __init__
    self._init_preview()
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 513, in _init_preview
    self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
  File "/usr/lib/python3/dist-packages/picamera/renderers.py", line 558, in __init__
    self.renderer.inputs[0].connect(source).enable()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2212, in enable
    prefix="Failed to enable connection")
  File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
    raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources 

Please let me know if I need to add the code from these python files, but my best bet is it is too intensive. Using python 3.7.

AxiomOfTruth
  • 315
  • 1
  • 2
  • 10

5 Answers5

14

Another program was using the camera. To prevent this from being an issue, either reboot or task kill the program using the camera.

AxiomOfTruth
  • 315
  • 1
  • 2
  • 10
3

I was trying to execute Pi Camera Python program from Thonny IDE and terminal when I got the picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources error.

Adding a camera.close() after camera.stop_preview() solved the issue.

Imran Khan
  • 61
  • 2
2

In my case, the problem was that I was asking for a too high resolution. I'm using a Raspberry Pi HQ Camera that can go up to 4056x3040, and instanciated my camera object with full res.
Lowering it to a more suitable res did the trick.

1

you should enable the camera. In command-line type 'raspi-config' and then enable camera

0

I had the same issue when I ran the code for second time. You need to close any application that is using picamera or else you can restart kernel and it will solve the issue.

Vilas
  • 51
  • 4