#include <opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main()
{
//initialize and allocate memory to load the video stream from camera
VideoCapture camera1(1 + cv::CAP_DSHOW);
/*camera1.set(CAP_PROP_FRAME_WIDTH, 320);
camera1.set(CAP_PROP_FRAME_HEIGHT, 240);*/
VideoCapture camera2(0 + cv::CAP_DSHOW);
//camera2.set(CAP_PROP_FRAME_WIDTH, 320);
//camera2.set(CAP_PROP_FRAME_HEIGHT, 240);
VideoCapture camera3(3 + cv::CAP_DSHOW);
if (!camera1.isOpened())
{
cout << "ERROR!camera 1 open failed" << endl;
return 1;
}
if (!camera2.isOpened())
{
cout << "ERROR!camera 3 open failed" << endl;
return 1;
}
if (!camera3.isOpened())
{
cout << "ERROR!camera 3 open failed" << endl;
return 1;
}
//grab and retrieve each frames of the video sequentially
Mat frame1;
camera1 >> frame1;
if (frame1.empty()) {
cerr &
OpenCV同时打开3个摄像头并保存为视频
最新推荐文章于 2023-12-03 12:33:15 发布