简体   繁体   English

Raspberry Pi Zero 和 OpenCV 上的网络摄像头损坏图像

[英]Corrupt image with webcam on Raspberry Pi Zero and OpenCV

I attached a USB webcam to my Raspberry Pi Zero W though an OTG cable.我通过 OTG 电缆将 USB 网络摄像头连接到我的 Raspberry Pi Zero W。 When I run my python script the OpenCV video capture at first gave me select timeout errors:当我运行我的 python 脚本时,OpenCV 视频捕获首先给了我选择超时错误:

import cv2 as cv
cap = cv.VideoCapture(0)
_, img = vs.read()
cv.imwrite(filename="image.jpg", img=img)

Then I tried:然后我尝试:

rmmod uvcvideo
modprobe uvcvideo nodrop=1 timeout=5000 quirks=0x80

It doesn't give select timeout errors anymore but the image seems corrupt.它不再出现选择超时错误,但图像似乎已损坏。 Here is an output image from the webcam:这是网络摄像头的输出图像:

图片来自网络摄像头

I fixed it a while ago and I thought I should answer my own question:我不久前修复了它,我想我应该回答我自己的问题:

vc.set(cv.CAP_PROP_FRAME_WIDTH, 480)
vc.set(cv.CAP_PROP_FRAME_HEIGHT, 360)

I just had to tell CV the correct width and height of the camera.我只需要告诉 CV 相机的正确宽度和高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM