运行python opencv脚本时出现“选择超时”错误

时间:2018-12-20 11:28:38

标签: python opencv linux-kernel webcam uvc

我正在尝试从USB 3.0网络摄像头捕获视频/图像提要。每当我尝试运行此代码时,该代码就会运行并捕获feed。但是,一段时间后,我得到“选择超时”。 错误不会被异常捕获。 有人可以帮我解决这个问题吗?

选择超时

OpenCV错误:Mat,文件/home/opencv-3.4.0/modules/core/include/opencv2/core/mat.inl.hpp中的断言失败(total()== 0 ||数据!= __null) ,第500行

try:

    while True:
        ret, frame = cap.read()
        if ret != True:
            break
        if stat == None:
            stat = ret
            print('[INFO] ---- Reading video feed')
            continue
        frame = cv2.resize(frame , (int(320/2),int(240/2)))
        video.write(frame)
        if stat1 == None:
            stat1 = ret
            print('[INFO] ---- Video recording on process')
            continue
        c+=1
        print(c)
        key = cv2.waitKey(30) & 0xFF
        if key == 27:
            break
        elif c == 1200:
            break
except Exception as e:

        print(e)
        sys.exit()

我也尝试过编辑“ uvcvideo”驱动程序参数

$ modprobe uvcvideo nodrop = 1超时= 6000

而且 启用的模块跟踪,

$ sudo echo 0xffff> / sys / module / uvcvideo / parameters / trace

在'dmesg'IMAGE

上观察到这些错误

我关注的链接: Select Timeout error in Ubuntu - Opencv

0 个答案:

没有答案