OpenCV同时打开双相机

#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;
}

猜你喜欢

转载自blog.csdn.net/KillMeHealMe/article/details/84023439