just do it

与其苟延残喘,不如纵情燃烧

多摄像头拼接

主要用到

hconcat
vconcat

capture和capture1分别捕获笔记本自带相机和外接相机的视频
hconcat[ A, B ,C]-->\(C=[ A, B ]\)
vconcat[ A, B ,C]-->\(C=[ A, B ]^T\)

主要代码
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <iostream>
#include <time.h>
#include<windows.h>
using namespace cv;
using namespace std;

Mat frame;
Mat frame1;
Mat b;
Mat b1;
 Mat roi_img_left;
 Mat roi_img_right;
 Mat roi_img_left1;
 Mat roi_img_right1;
char fileNameBmpLeft[64];
char fileNameBmpRight[64];
int calibStep = 1;
int ret = 0;

int main()
{
	VideoCapture capture(0);

	VideoCapture capture1(1);

	while (1)
	{
		capture1 >> frame1;
		capture >> frame;
		imshow("d", frame);
		imshow("d1", frame1);
		cout << frame1.size << endl;

		roi_img_left = frame(Range(0, 480),  Range(0, 320));
		roi_img_right = frame(Range(0, 480),  Range(320, 640));
		
		roi_img_left1 = frame1( Range(0, 480),  Range(0, 320));
		roi_img_right1 = frame1( Range(0, 480),  Range(320, 640));

		Mat combine, combine1, combine2;

		hconcat(roi_img_left, roi_img_right1, combine1);
		hconcat(roi_img_left1, roi_img_right, combine2);
		vconcat(combine1, combine2, combine);

		imshow("【display】", combine);
		waitKey(30);
	}

	capture.release();
	system("pause");
	return 0;
}
posted @ 2019-05-19 21:48  elong1995  阅读(967)  评论(0编辑  收藏  举报