天天看點

windows下opencv同時開啟兩個攝像頭采集程式

親測可用的代碼,至于為什麼把

VideoCapture cap();//寫成全局變量,友善寫其他C程式
VideoCapture capcap();
Mat frame;
Mat frame2;
           

寫在全局變量,是為了在其他C檔案裡調用

隻要在其他C檔案加上

extern 語句就可以了。

#include<opencv2/opencv.hpp>
#include<thread>
using namespace cv;

VideoCapture cap();//寫成全局變量,友善寫其他C程式
VideoCapture capcap();
Mat frame;
Mat frame2;

int main()
{


    if (!capcap.isOpened())return ;
    if (!cap.isOpened())return ;





    while (waitKey() != )
    {
        capcap >> frame2;
        imshow("攝像頭2", frame2);
        cap >> frame;
        imshow("攝像頭1", frame);
    }
    return ;
}