Cannot find any webcams while try to run the classify.py

I am actually trying to run my model locally in Raspberry Pi 4 with Raspberry Pi Camera Module V2. The camera is working fine with the edge-impulse-linux and edge-impulse-runner. When I try to run the classify.py in the Linux python sdk it produces this exception.

MODEL: /home/pi/modelfile.eim
Loaded runner for "Susmita Sarkar / Feasibility of Automatic Garment Measurement Project:1"
Looking for a camera in port 0:
Looking for a camera in port 1:
[ WARN:0@0.195] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video1): can't open camera by index
[ WARN:0@0.197] global obsensor_stream_channel_v4l2.cpp:82 xioctl ioctl: fd=6, req=-2140645888
[ WARN:0@0.197] global obsensor_stream_channel_v4l2.cpp:138 queryUvcDeviceInfoList ioctl error return: 25
[ERROR:0@0.201] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
Looking for a camera in port 2:
[ WARN:0@0.202] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video2): can't open camera by index
[ WARN:0@0.202] global obsensor_stream_channel_v4l2.cpp:82 xioctl ioctl: fd=6, req=-2140645888
[ WARN:0@0.202] global obsensor_stream_channel_v4l2.cpp:138 queryUvcDeviceInfoList ioctl error return: 25
[ERROR:0@0.206] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
Looking for a camera in port 3:
[ WARN:0@0.206] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video3): can't open camera by index
[ WARN:0@0.206] global obsensor_stream_channel_v4l2.cpp:82 xioctl ioctl: fd=6, req=-2140645888
[ WARN:0@0.206] global obsensor_stream_channel_v4l2.cpp:138 queryUvcDeviceInfoList ioctl error return: 25
[ERROR:0@0.210] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
Looking for a camera in port 4:
[ WARN:0@0.210] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video4): can't open camera by index
[ WARN:0@0.210] global obsensor_stream_channel_v4l2.cpp:82 xioctl ioctl: fd=6, req=-2140645888
[ WARN:0@0.210] global obsensor_stream_channel_v4l2.cpp:138 queryUvcDeviceInfoList ioctl error return: 25
[ERROR:0@0.214] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
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

Hello @Tony_sebastian,

I think that is an issue with OpenCV.
Could you check this to see if it helps: VideoCapture can't open camera by index · Issue #19527 · opencv/opencv · GitHub

Best,

Louis

Do any of these files exist actually /dev/video*?

If not, then RPi does not see the camera so you’ll need to get Linux to attach to the hardware camera.

The problem is actually solved. I forget to enable the legacy camera.

2 Likes