我通过opencv拍摄了一个图像,以检查我对网络摄像头是否有问题,但是网络摄像头正在工作。现在,在下面提到的代码中,仅执行其他语句,而帧一直都不是。
video = cv2.VideoCapture(0)
if video.isOpened():
while True:
check, frame = video.read()
if frame != None:
cv2.imshow("Color Frame", frame)
key = cv2.waitKey(50)
if key == ord("q"):
break
else:
print("Frame not available")
print(video.isOpened())
在Raspberry Pi 3中,我必须做以下操作才能使其工作:
$ sudo modprobe bcm2835-v4l2
cv2.VIDEOCAPTURE.READ()返回false,无,解决方案是运行:conda install -c conda -forge ffmpegconda install -c conda -forge opencv