我通过 opencv 拍摄了一张图像,以检查网络摄像头是否有问题,但网络摄像头可以正常工作。现在在下面提到的代码中,只有 else 语句被执行,而 frame 一直没有。
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
关于python - cv2.VideoCapture.read() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42677149/