python - 运行 python opencv 脚本时出现“选择超时”错误
问题描述
我正在尝试从 USB 3.0 网络摄像头捕获视频/图像馈送。每当我尝试运行此代码时,代码都会运行并捕获提要。但是,过了一会儿我得到“选择超时”。错误不会被异常捕获。有人可以帮我解决这个问题吗?
select timeout
OpenCV Error: Assertion failed (total() == 0 || data != __null) in Mat, file /home/opencv-3.4.0/modules/core/include/opencv2/core/mat.inl.hpp, line 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 timeout=6000
还有,启用模块跟踪,
$ sudo echo 0xffff > /sys/module/uvcvideo/parameters/trace
在“dmesg”图像上观察到这些错误
我遵循的链接: 在 Ubuntu 中选择超时错误 - Opencv
解决方案
推荐阅读
- javascript - 刷新页面时Vue.js路由错误
- javascript - VBA Javascript 弹出窗口
- windows - Appium 会话未在 Windows 中启动
- python - 如何在数据框中获取 sha256().hexdigest()
- python - 从 s3 存储桶中获取具有特定子字符串的文件列表
- elasticsearch - 嵌套聚合,术语 -> 术语 -> 计数 Elasticsearch
- javascript - 如何将项目更新到 PostgreSQL 中的 jsonb 数据类型列
- javascript - 如何将数组中的整数替换为空字符串jQuery
- mysql - MYSQL group by 当大于 X
- db2 - DSNURWBG - 输入字段 ffffff 不完全在输入记录中