其他分享
首页 > 其他分享> > opencv打开摄像头

opencv打开摄像头

作者:互联网

opencv打开摄像头

#include <opencv2/opencv.hpp>
#include <iostream>


using namespace cv;
using namespace std;


int main() 
{
    cv::namedWindow("win1", cv::WINDOW_AUTOSIZE);
    VideoCapture capture1(1);
    //capture1.get(cv::CAP_PROP_FRAME_WIDTH);
    //capture1.get(cv::CAP_PROP_FRAME_HEIGHT);
    capture1.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
    capture1.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);

    Mat img1;

    while (capture1.isOpened())
    {
        bool isSuccess = capture1.read(img1);
        if (isSuccess)
        {
            imshow("win1",img1);
        }

        std::cout << img1.cols<<"                  "<<img1.rows << std::endl;
        waitKey(1);
    }

    return 0;
}

 

 

 

#####################

标签:CAP,FRAME,capture1,PROP,opencv,img1,打开,cv,摄像头
来源: https://www.cnblogs.com/herd/p/16386986.html