Raspberry Pi 3B not detecting Arducam IMX519 camera with picamera

I’ve got an Arducam IMX519 that my Raspberry Pi 3B just won’t recognize. I know the Pi itself is fine because I swapped in a different camera and it worked. Our IT guy also couldn’t get the IMX519 to talk on either a 3B or a 4.

I followed the setup instructions on the Arducam site, tried several code samples from there, and even wiped the Pi and started over. The camera never shows up in any command output.

Here’s the test script I’ve been running:

from picamera import PiCamera
from time import sleep

camera = PiCamera()
camera.start_preview()
sleep(5) # Wait for the camera to adjust to lighting conditions
camera.capture('/home/pi/image.jpg')
camera.stop_preview()

And this is what I get when I run it:

>>> %Run -c $EDITOR_CONTENT
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera
    self._camera = mo.MMALCamera()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in __init__
    super(MMALCamera, self).__init__()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 631, in __init__
    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 create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 4, in <module>
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in __init__
    self._init_camera(camera_num, stereo_mode, stereo_decimate)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 459, in _init_camera
    raise PiCameraError(
picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.
>>>

Any ideas? I’ve already tried raspi-config to enable the camera.

Thanks for the detailed log. Before we dig into the config, can you generate a diagnostic report from the Pi? I’ve sent you our camera bug report tool via private message.

Once you’ve got it on the Pi, make it executable and run it:

chmod +x ./arducam-camera-bug-report
./arducam-camera-bug-report

It’ll write an arducam-bug-report.txt in the current directory. Send that file back to me (private message is fine) and I’ll take a look.

I ran the tool and it generated arducam-bug-report.txt. I’ve sent the file over in a private message. Let me know what you find.

Got the report, thanks. Looking at it, the camera isn’t actually enabled in the config file. The IMX519 needs its dtoverlay entry set up correctly, and that’s missing or incorrect in your current setup.

Follow this guide for the IMX519 config changes:

https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Quick-Start-Guide/#software-guide-for-imx519-camera

Pay close attention to where the dtoverlay line ends up in config.txt. Give that a try and then test with libcamera-still.

Found the problem with the config. My config.txt had two [All] sections, and I’d put the IMX519 dtoverlay in the top one. Deleting that top [All] block and putting the dtoverlay in the bottom [All] section fixed it — libcamera-still runs and captures images now.

But my Python script still throws the same memory error. It’s using the old picamera library. The script is on my USB drive at /media/pi/TEAM FELIX/RPi offload/PDAF Camera.py, but the test code is the same as before:

#test code
from picamera import PiCamera
from time import sleep

camera = PiCamera()
camera.start_preview()
sleep(5)  # Wait for the camera to adjust to lighting conditions
camera.capture('/home/pi/image.jpg')
camera.stop_preview()

Logs:

>>> %Run 'PDAF Camera.py'
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera
    self._camera = mo.MMALCamera()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in __init__
    super(MMALCamera, self).__init__()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 631, in __init__
    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 create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/media/pi/TEAM FELIX/RPi offload/PDAF Camera.py", line 32, in <module>
    camera = PiCamera()
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in __init__
    self._init_camera(camera_num, stereo_mode, stereo_decimate)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 459, in _init_camera
    raise PiCameraError(

So libcamera sees it, but picamera doesn’t. What am I missing?

Glad libcamera-still is working — that confirms the camera and the dtoverlay are fine now. The remaining error is because your Python code is still going through the legacy picamera/MMAL path, which is deprecated and doesn’t play well with the IMX519.

Switch that script over to picamera2. Here’s the user guide:

https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/PiCamera2-User-Guide/

And since you mentioned PDAF, there’s an autofocus example here that should be close to what you need:

Replace the from picamera import PiCamera stuff with picamera2 and the ENOMEM error should go away.

That did it. I rewrote the script with picamera2 and it’s working now — no more MMAL/ENOMEM errors, and autofocus behaves. Thanks for the help!