VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV

从git上下载了个检测手势的SSD项目,一运行报出如下的错误:

VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Device or resource busy
OpenCV(3.4.1) Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /io/opencv/modules/imgproc/src/color.cpp, line 11115

出现这种错误原因之一是重复打开VideoCapture

打开代码发现cap = cv2.VideoCapture(0)调用了两次,删除掉一处就行了。

根本原因是打开摄像头失败了,所以其他的原因可能是设备号错了,比如有的摄像头为设备1,则要改成VideoCapture(1),

还有一种原因是找不到v4l的so库,需要找到v4l1compat.so,然后export LD_PRELOAD=/usr/lib64/v4l/v4l1compat.so

作者:帅得不敢出门

你可能感兴趣的:(人工智能)