Closed adthoms closed 1 year ago
Hi @adthoms ,
I don't have a Pi camera to reproduce the errors right now, but maybe we can debug it together. This error appeared to me when the camera stream couldn't be opened (if it's already used by other applications or when the arguments are wrong).
Is the camera stream opening outside the .py file? You can test typing in the terminal:
raspistill -t 1000
If it still does not open, can you try:
camera.close()
after camera.stop_preview()
(as this comment).Looking forward to your feedback.
For reference, we use Pi Camera 2 NoIR
Hi @debOliveira
if we run the raspistill -t 1000 command we get an error that says
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC mmal: camera component couldn't be enabled mmal: main: Failed to create camera component mmal: Failed to run camera app. Please check for firmware updates
Rebooting, reducing the resolution, and adding Camera.close() resulted in the same Out of Resource error. Is there anything else we can try?
Looking forward to your feedback.
Hi @adthoms
The raspistill
command is native to the Pi userland
library. The problem is thus not in the .py code but in accessing the PiCam interface. Some process/daemon must be running in the background and allocating the camera.
Could you disclose which module you are using and the command vcgencmd get_camera
output?
Collecting some troubleshooting from StackOverflow, I would do the following steps:
sudo raspi-config
, reboot, reactivate, and reboot again (if this solves, you can add a permanent configuration to set this up on boot)sudo /etc/init.d/motion stop
before capturing (solved this case)If the problem persists, you can address on the userland
repo issues page.
I'll close this issue, as the problem is not in our code. However, feel free to continue the discussion in this thread :)
@debOliveira
We suspect this issue is caused by incompatibility with our hardware (and consequently software). In our build, we are using three Raspberry Pi 4 model b units, which are incompatible with the last version of raspbian). According to the README.md in MoCapRasp/client, we assume MoCapRasp has only been tested using Rasbian OS on Raspberry 3bs. Further, it appears the libcamera software stack on Rasberry Pi OS (which is required for Raspberry Pi 4 model b) is incompatible with legacy camera support, suggesting we should bump Picamera to Picamera2 as per the official documentation, Section Preparing the Software. Given this, we will work through these compatibility issues on our fork and make modifications as necessary. Thank you again for your help and for open-sourcing your work!
@adthoms
I used Rasberry Pi 4b in the project with Raspbian 32bits. I have a modified userland repo for the timestamp export. You can try with this older version.
We are open to pull request for the corrections :)
@debOliveira
Thanks again for your help. As per your previous post, vcgencmd get_camera
gives:
supported=1 detected=1, libcamera interfaces=0
We are using Camera Module 3 NoIR modules. We currently have raspi-config-->Interface Options-->Lecacy Camera set to enabled
. Running libcamera-hello
gives:
Preview window unavailable
[0:21:09.330592447] [3783] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+22-923f5d70
ERROR: *** no cameras available ***
Disabling legacy support, vcgencmd get_camera
gives:
vcgencmd get_camera
supported=0 detected=0, libcamera interfaces=0
while libcamera-hello
gives:
Preview window unavailable
[0:05:32.393719986] [1358] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+22-923f5d70
[0:05:32.548944857] [1360] INFO RPI raspberrypi.cpp:1476 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media2 and ISP device /dev/media1
[0:05:32.550601616] [1358] INFO Camera camera.cpp:1028 configuring streams: (0) 2304x1296-YUV420
[0:05:32.551252764] [1360] INFO RPI raspberrypi.cpp:851 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
#0 (0.00 fps) exp 27041.00 ag 1.12 dg 1.02
and executes successfully. Note that the documentation for picamera does not mention Camera Module 3, and the last commit made in the picamera repository was made three years ago -- Camera Module 3 NoIR modules were released in 2023. Using the following first example from the Picamera2 Python library documentation.
from picamera2 import Picamera2, Preview
import time
picam2 = Picamera2()
camera_config = picam2.create_preview_configuration()
picam2.configure(camera_config)
picam2.start_preview(Preview.QTGL)
picam2.start()
time.sleep(2)
picam2.capture_file("test.jpg")
the program runs successfully. Given this, we will operate under the assumption that Camera Module 3 requires:
disabled
We will keep you updated on our progress towards getting MoCapRasp operational with Camera Module 3 modules!
@adthoms
Would you have any update on this issue?
@debOliveira
In my fork of MoCapRasp, I have updated calibCapture.py for module 3 cameras. I have also done additional refactors for kalibr compatibility and UI updates. You will notice substantial changes have been made to how images are captured, and this is largely due to the overhauled Picamera2 API. I have had to move to other pressing work for my PhD, though we have undergraduate students working on updating the remaining code in client
and server
to suit. It is tough to give a timeline on this, though slowly we are making our way through the repo.
@adthoms
Thank you for your collaboration! I added the link to your fork in the README of the repo.
Describe the bug Every time the calibCapture.py code is run, a long error pops up with the end of it saying "picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources". We tried many solutions and weren't able to fix the error. Not sure if its a software or hardware issue. Could indicate a problem with the system while trying to establish a connection.
To Reproduce
Expected behavior The expected behavior of the code is to initialize the Raspberry Pi camera, start the camera preview in a specified window, set up camera settings (shutter speed, exposure mode, color effects, etc), and continuously capture images every 5 seconds.
(this is the complete error that is shown)
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))0x255aea0 (ENOSPC) mmal: mmal_connection_enable: output port couldn't be enabled Traceback (most recent call last): File "/home/pi/MoCapRasp/calib/calibCapture.py", line 8, in
with picamera.PiCamera(resolution=(4608,2592), framerate=15,
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 512, in _init_preview
self._preview = PiNullSink(
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 2210, in enable
mmal_check(
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