【问题标题】:How to get frames from c920 camera using OpenCV4 C++如何使用 OpenCV4 C++ 从 c920 相机获取帧
【发布时间】:2019-07-13 13:00:31
【问题描述】:

我正在尝试从 Logitec c920 相机获取帧 并向他们展示。 摄像头似乎在工作,但显示窗口上没有显示任何内容。

我尝试配置所有相机设置,但没有。 我错过了什么???


    #include "pch.h"
    #include <iostream>
    #include "opencv2\imgcodecs.hpp"
    #include "opencv2\core.hpp"
    #include "opencv2\highgui.hpp"
    #include "opencv2\videoio.hpp"

    using namespace std;
    using namespace cv;

    int main()
    {

        VideoCapture camera(CAP_ANY);

        Mat frame;
        namedWindow("x", WINDOW_AUTOSIZE);

        camera.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G'));
        camera.set(CAP_PROP_FRAME_WIDTH, 1920);
        camera.set(CAP_PROP_FRAME_HEIGHT, 1080);


        while (1)
        {

            camera.read(frame);
            imshow("x", frame);

        }

        waitKey(0);
        return 0;

    }

【问题讨论】:

    标签: c++ opencv4


    【解决方案1】:

    你必须在每一帧之后加上waitKey(int delay)。您的 while 循环应如下所示:

    while (1)
        {
    
            camera.read(frame);
            imshow("x", frame);
            waitKey(1);
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 2022-06-12
      • 2017-09-25
      相关资源
      最近更新 更多