Issue of enabling Pi Camera


We just got PiCar-X. Everything works fine, except the camera.
It seems that the camera can be detected by “libcamera”. but python program can not operate it.

We have the Raspberry Pi 4B. We tested the following:

$ Libcamera-hello

Made X/EGL preview window
[0:02:20.528840535] [1925] INFO Camera camera_manager.cpp:297 libcamera v0.0.5+83-bde9b04f
[0:02:20.593701574] [1926] INFO RPI vc4.cpp:437 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:02:20.593934633] [1926] INFO RPI pipeline_base.cpp:1101 Using configuration file ‘/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml’
[0:02:20.596297208] [1925] INFO Camera camera.cpp:1033 configuring streams: (0) 1296x972-YUV420
[0:02:20.597644266] [1926] INFO RPI vc4.cpp:565 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA

$ libcamera-hello --list-cameras
Available cameras

0 : ov5647 [2592x1944] (/base/soc/i2c0mux/i2c@1/ov5647@36)
Modes: ‘SGBRG10_CSI2P’ : 640x480 [58.92 fps - (16, 0)/2560x1920 crop]
1296x972 [43.25 fps - (0, 0)/2592x1944 crop]
1920x1080 [30.62 fps - (348, 434)/1928x1080 crop]
2592x1944 [15.63 fps - (0, 0)/2592x1944 crop]

$ sudo python3
Launching villib 0.0.6 …
imshow start …

press Ctrl+C to exit
mmal: mmal_vc_component_create: failed to create component ‘’ (1:ENOMEM)
mmal: mmal_component_create_core: could not create component ‘’ (1)
Exception in thread camera_satrt:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/picamera/”, line 456, in _init_camera
self._camera = mo.MMALCamera()
File “/usr/lib/python3/dist-packages/picamera/”, line 2279, in init
super(MMALCamera, self).init()
File “/usr/lib/python3/dist-packages/picamera/”, line 631, in init
File “/usr/lib/python3/dist-packages/picamera/”, line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b’’: Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.9/”, line 954, in _bootstrap_inner
File “/usr/lib/python3.9/”, line 892, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/lib/python3.9/dist-packages/vilib-0.0.6-py3.9.egg/vilib/”, line 564, in camera_clone
File “/usr/local/lib/python3.9/dist-packages/vilib-0.0.6-py3.9.egg/vilib/”, line 570, in camera
camera = PiCamera()
File “/usr/lib/python3/dist-packages/picamera/”, line 431, in init
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File “/usr/lib/python3/dist-packages/picamera/”, 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.

Part of config.txt file

Automatically load overlays for detected cameras


Automatically load overlays for detected DSI displays


Enable DRM VC4 V3D driver


Disable compensation for displays with overscan


Enable host mode on the 2711 built-in XHCI USB controller.

This line should be removed if the legacy DWC2 controller is required

(e.g. for USB device mode) or if USB support is not required.


Run as fast as firmware / board allows


Can anyone please help me resolve this issue? Thanks very much in advance.

  1. What version of Raspberry Pi system are you currently using? Please let us know so that we can analyze the problem.

  2. Please check if the wiring direction of the camera is correct.

  3. Test whether the system recognizes the camera by commanding sudo raspistill -o test.png.

  4. Make sure the system has enabled the camera function, execute sudo raspi-config, enter the setting page and select Interfacing Options, then press Enter.
    Then select Camera and use the arrow keys on your keyboard to select → to complete the Camera settings.


Thanks for your reply.

Our version is Raspbian 11(bullseyes, legacy).

We have solved the problem. By:

  1. removing the camera_auto_detect=1
  2. add start_x=1
  3. change the gpu_mem =128 to 256

Not sure the third one is necessary or not (did not test it). Anyway, PiCamera is working now. And the libcamera command is not working anymore.
Hope this can be helpful for someone else who experienced same problem.

1 Like