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

Posted 嵌入式爱好者-超

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV学习-打开两个USB相机和视频相关的知识,希望对你有一定的参考价值。

打开两个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;

以上是关于OpenCV学习-打开两个USB相机和视频的主要内容,如果未能解决你的问题,请参考以下文章