gpt4 book ai didi

c++ - OpenCV:在捕获时更改 VideoCapture 的分辨率

转载 作者:太空宇宙 更新时间:2023-11-03 22:25:25 24 4
gpt4 key购买 nike

我在 Windows 10 64 位上使用 OpenCV 3.1.0。我希望能够在网络摄像头仍在工作时设置网络摄像头的分辨率。相机工作后很容易设置分辨率。但是当网络摄像头正在捕获时我无法设置分辨率。

这是我的代码:

cv::VideoCapture cap(0);
cap.set(cv::CAP_PROP_FRAME_WIDTH, 0x7FFFFFFF); // working
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 0x7FFFFFFF); // working

while (true) {
cv::Mat frame;
cap >> frame;
if (!frame.data) continue;
cv::imshow("test", frame);
if (cv::waitKey(1) >= 0) break;

int newHeight = 500 + rand() % 4 * 100;
cap.set(cv::CAP_PROP_FRAME_HEIGHT, newHeight); // not working
}

int newHeight = 500 + rand() % 4 * 100;
cap.set(cv::CAP_PROP_FRAME_HEIGHT, newHeight); // not working

最佳答案

我最好的猜测是网络摄像头不支持您尝试的 CAP_PROP_FRAME_HEIGHT 值。如果将相机连接到 Linux 盒子,则可以使用 v4l2-ctl -d 0 --list-formats-ext 列出支持的视频格式。以下是 Microsoft LifeCam Cinema 的输出摘录:

    Index       : 1
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : Motion-JPEG
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
Size: Discrete 1280x720
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
...

我最近没有检查在Windows上是否有类似v4l2-ctl的东西,它使用UVC从相机查询信息。最近的网络摄像头通常支持 UVC。

关于c++ - OpenCV:在捕获时更改 VideoCapture 的分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41009443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com