cv2.VideoCapture(1)报错问题

2024-01-23 09:44:24 浏览数 (2)

代码语言:javascript复制
[ERROR:0@6.065] global obsensor_uvc_stream_channel.cpp:156 cv::obsensor::getStreamChannelGroup Camera index out of range
Traceback (most recent call last):
  File "F:new-VScode-opencvProject2-mainSnakeGameAiVirtualMouseProject.py.py", line 27, in <module>
    img = detector.findHands(img)
  File "F:new-VScode-opencvProject2-mainSnakeGameHandTrackingModule.py", line 21, in findHands
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
cv2.INerrorFO: : OpenCV(4.8.1) D:aopencv-pythonopencv-pythonopencvmodulesimgprocsrccolor.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
Created
 TensorFlow Lite XNNPACK delegate for CPU.

配置完环境,使用开源码发现出现如此问题,调试后;得知是cap = cv2.VideoCapture(1)问题,这里的1是外设摄像头,内置的是零(比如笔记本就是零)

0 人点赞