OpenCV学习-打开两个USB相机和视频

打开两个USB相机

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

你可能感兴趣的:(opencv,opencv)