#include <iostream> #include <cv.h> #include <opencv.hpp> using namespace std; using namespace cv; //row:height //col:width #define CAM_WIDTH 640 #define CAM_HEIGHT 360 int main() { Mat img1; VideoCapture capture( 0 ); Mat img2; VideoCapture capture2( 1 ); Mat roi_img( CAM_HEIGHT, CAM_WIDTH * 2, CV_8UC3 ); if (!capture.isOpened()) { std::cout << "1카메라가 연결 되어있지 않습니다." << std::endl; return -1; } if (!capture2.isOpened()) { std::cout << "2카메라가 연결 되어있지 않습니다." << std::endl; return -1; } // namedWindow("image",1); // namedWindow("image2",1); namedWindow("roi",1); int j = 1; while ( 1 ) { capture.set( CV_CAP_PROP_FRAME_WIDTH, CAM_WIDTH ); capture.set( CV_CAP_PROP_FRAME_HEIGHT, CAM_HEIGHT ); capture >> img1; capture2.set(CV_CAP_PROP_FRAME_WIDTH,640); capture2.set(CV_CAP_PROP_FRAME_HEIGHT,360); capture2 >> img2; // imshow("1",img1); // imshow("2",img2); Rect roi = Rect( 0, 0, CAM_WIDTH, CAM_HEIGHT ); img2.copyTo( roi_img(roi) ); roi = Rect( CAM_WIDTH, 0, CAM_WIDTH, CAM_HEIGHT ); img1.copyTo( roi_img(roi) ); imshow("roi",roi_img); if ( waitKey( 1 ) % 256 == 27 ) break; } }
최근댓글