camera - 在 python 中使用 .read() 显示时如何更改 cv.VideoCapture(0) 帧大小?树莓派和 OpenCv
问题描述
我运行以下代码来扫描实时视频源中的二维码。但是,弹出的窗口很小,我必须拖动角落才能看到实时提要的全尺寸。如果我将 .set 3 和 4 更改为更大的值(但成比例),我会得到一个不正确的古怪图像。有没有办法在我运行代码时自动增加视频源窗口的大小,同时保持质量?我正在使用 Raspberry Pi 高质量相机。
cap = cv.VideoCapture(0)
cap.set(3,640)
cap.set(4,480)
timeout = time.time() + 8 # Number of seconds to scan for QR codes
while True:
sucess, img = cap.read()
for barcode in decode(img):
myData = barcode.data.decode('utf-8')
print(myData)
cv.imshow('Result',img)
cv.waitKey(1)
if time.time() > timeout:
break
cv.destroyAllWindows()
解决方案
推荐阅读
- git - Git push origin Permission to * denied fatal: 无法从远程存储库读取
- ios - Google 登录 IOS Swift 4 AppDelegate 错误
- xml - xsd - 如何处理属性
- python - ValueError:需要超过 1 个值才能解压(目录)
- django - 在 Django 中按整数字段的内容搜索
- java - 我们如何在不使用 catalina.properties 的情况下将属性传递给 tomcat 上下文,或者是否有更好的方法来注入属性?
- php - 更改 Woocommerce 存款插件付款计划中的百分比小数精度
- nginx - 在 AWS EC2 (Ubuntu 16 AMI) 中使用 nginx 作为代理设置 neo4j
- sql-server - Django DecimalField 不尊重 max_digits 并导致缓冲区溢出/截断
- firebase - firebase 数据库:从 CLI 更新 - 一个项目中的多个数据库