import numpy as np import cv2
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
我的Debian计算机上的视频捕获演示(opencv 3.2.0)不起作用,我不明白如何解决它 . 我在Windows上尝试过它,效果很好 .
我尝试使用VideoCapture(-1)VideoCapture(0)但它似乎不起作用..
我该如何解决?谢谢
OpenCV错误:断言失败(scn == 3 || scn == 4)在cvtColor中,文件/io/opencv/modules/imgproc/src/color.cpp,第9748行追溯(最近一次调用最后一次):文件“确定.py“,第11行,灰色= cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)cv2.error:/io/opencv/modules/imgproc/src/color.cpp:9748:错误:(-215)scn == 3 || scn == 4在函数cvtColor中
$ v4l2-ctl --list-devices
UVC Camera (046d:0809)(usb-0000:00:14.0-3): /dev/video1
USB2.0 HD UVC WebCam (usb-0000:00:14.0-5): /dev/video0
我试过了
ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv
和摄像头工作..
1 回答
为什么
VideoCapture(1)
?你的系统上有两个摄像头吗?你测试过了
在
/dev/video0
所以它应该是VideoCapture(0)
.