打开两个USB相机
#include<opencv2/opencv.hpp>
#include<thread>
using namespace cv;
int main()
{
VideoCapture CapLeft(0);
VideoCapture CapRight(1);
Mat frameLeft;
Mat frameRight;
if (!CapRight.isOpened())return 0;
if (!CapLeft.isOpened())return 0;
while (waitKey(30) != 27)
{
CapRight >> frameRight;
imshow("右摄像头", frameRight);
CapLeft >> frameLeft;
imshow("左摄像头", frameLeft);
}
return 0;
}
打开两个视频
#include<opencv2/opencv.hpp>
#include<thread>
using namespace cv;
int main()
{
VideoCapture CapLeft("D:/images/IMG_4753.mp4");
VideoCapture CapRight("D:/images/IMG_4755.mp4");
Mat frameLeft;
Mat frameRight;
if (!CapRight.isOpened())return 0;
if (!CapLeft.isOpened())return 0;
while (waitKey(30) != 27)
{
CapRight >> frameRight;
imshow("右摄像头", frameRight);
CapLeft >> frameLeft;
imshow("左摄像头", frameLeft);
}
return 0;
}