当我尝试用opencv和python开始视频采集时,它根本不加载。不显示出任何问题,也不返回任何东西。没什么!
代码是最简单的:
import cv2
import sys
video_capture = cv2.VideoCapture(0)
while True:
ret, frame = video_capture.read()
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
cv2.destroyAllWindows()这是运行这个程序的结果。

如果我一行行地运行代码,它就会卡在这里。

如果在执行最后一行时按Ctrl+C,这就是它告诉我的:
Trying to dispose element pipeline0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.发布于 2021-12-15 14:20:39
也许不是真正的解决方案,但要尝试的一件事情是指定视频后端,如下所示:
video_capture = cv2.VideoCapture(0, CAP_V4L2)https://stackoverflow.com/questions/70351669
复制相似问题