Cannot find any webcams when running classify.py

Question/Issue:
I wanna run my model locally on my Raspberry Pi 3B and a Raspberry Pi Camera Module V2. When I run edge-impulse-linux or edge-impulse-linux-runner the camera is detected and it works perfectly fine. However, when I try to run the classify.py example it returns this:

MODEL: /home/pi/linux-sdk-python/examples/image/models/FOMO-int8.eim
Loaded runner for "Benjamin / Real-Time Object Tracking for Autonomous UAVs"
Looking for a camera in port 0:
Looking for a camera in port 1:
[ WARN:0] global /tmp/pip-wheel-a8gfdc_n/opencv-python_13563f08137a4b20bc4dfee05bcbf854/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video1): can't open camera by index
Looking for a camera in port 2:
[ WARN:0] global /tmp/pip-wheel-a8gfdc_n/opencv-python_13563f08137a4b20bc4dfee05bcbf854/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video2): can't open camera by index
Looking for a camera in port 3:
[ WARN:0] global /tmp/pip-wheel-a8gfdc_n/opencv-python_13563f08137a4b20bc4dfee05bcbf854/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video3): can't open camera by index
Looking for a camera in port 4:
[ WARN:0] global /tmp/pip-wheel-a8gfdc_n/opencv-python_13563f08137a4b20bc4dfee05bcbf854/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video4): can't open camera by index
Traceback (most recent call last):
  File "/home/pi/linux-sdk-python/examples/image/classify.py", line 129, in <module>
    main(sys.argv[1:])
  File "/home/pi/linux-sdk-python/examples/image/classify.py", line 81, in main
    raise Exception('Cannot find any webcams')
Exception: Cannot find any webcams

The camera should be in port 0.

v4l2-ctl --list-devices:

unicam (platform:3f801000.csi):
        /dev/video0
        /dev/video1
        /dev/media3

bcm2835-codec-decode (platform:bcm2835-codec):
        /dev/video10
        /dev/video11
        /dev/video12
        /dev/video18
        /dev/video31
        /dev/media2

bcm2835-isp (platform:bcm2835-isp):
        /dev/video13
        /dev/video14
        /dev/video15
        /dev/video16
        /dev/video20
        /dev/video21
        /dev/video22
        /dev/video23
        /dev/media0
        /dev/media1

v4l2-ctl --device=/dev/video0 --all:

Driver Info:
        Driver name      : unicam
        Card type        : unicam
        Bus info         : platform:3f801000.csi
        Driver version   : 5.15.32
        Capabilities     : 0xa5a00001
                Video Capture
                Metadata Capture
                Read/Write
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x25200001
                Video Capture
                Read/Write
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : unicam
        Model            : unicam
        Serial           :
        Bus info         : platform:3f801000.csi
        Media version    : 5.15.32
        Hardware revision: 0x00000000 (0)
        Driver version   : 5.15.32
Interface Info:
        ID               : 0x03000006
        Type             : V4L Video
Entity Info:
        ID               : 0x00000004 (4)
        Name             : unicam-image
        Function         : V4L2 I/O
        Flags         : default
        Pad 0x01000005   : 0: Sink
          Link 0x02000008: from remote pad 0x1000002 of entity 'imx219 10-0010': Data, Enabled, Immutable
Priority: 2
Video input : 0 (unicam-image: ok)
Format Video Capture:
        Width/Height      : 640/480
        Pixel Format      : 'BGR3' (24-bit BGR 8-8-8)
        Field             : None
        Bytes per Line    : 1920
        Size Image        : 921600
        Colorspace        : sRGB
        Transfer Function : sRGB
        YCbCr/HSV Encoding: ITU-R 601
        Quantization      : Full Range
        Flags             :

Any ideas?

Hello @bgemperl,

Which OS are you using?
Did you enabled the Raspberry Pi Camera in the raspi config?

Regards,

Louis

tldr: Turn on legacy mode in raspi-config

HI @louis

I am using Raspbian 11 bullseye. There is only the option to turn on legacy mode. I thought I had already tried turning that on with no success, but I might have not rebooted. This time I did and the problem is solved, thanks!

v4l2-ctl --list-devices now returns this, which is more aligned with what I have seen from others:

bcm2835-codec-decode (platform:bcm2835-codec):
        /dev/video10
        /dev/video11
        /dev/video12
        /dev/video18
        /dev/video31
        /dev/media2

bcm2835-isp (platform:bcm2835-isp):
        /dev/video13
        /dev/video14
        /dev/video15
        /dev/video16
        /dev/video20
        /dev/video21
        /dev/video22
        /dev/video23
        /dev/media0
        /dev/media1

mmal service 16.1 (platform:bcm2835-v4l2-0):
        /dev/video0

Hello @bgemperl ,

Glad to hear that! Thanks for sharing your solution.

Regards,

Louis