Reputation: 27
(On Raspberry Pi 5) I am using a python script (control.py
) to start another python script (main.py
) in a separate thread. main.py uses cv2 to get frames from a webcam attached to my Raspberry Pi. control.py
has an interval mode, meaning it starts main.py, which executes until a fixed time is reached, pauses, and then starts main.py
again. The first time, everything works flawlessly. However, the second time, I get this error:
[ERROR:[email protected]] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range [ WARN:[email protected]] global cap_v4l.cpp:999 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
I am calling cap.release()
and cv2.destroyAllWindows() when exiting main.py.
I figured the issue might be that cap.release()
is not working as expected. But if the resource is still busy, the error should be "Device or resource busy", according to this question.
Upvotes: 1
Views: 228