Last active
January 20, 2016 13:12
-
-
Save RDCH106/2dc3be1cf2e9344ba65b to your computer and use it in GitHub Desktop.
Display 2 Images in 1 Window with OpenCV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "opencv2/opencv.hpp" | |
int display(){ | |
//cv::VideoCapture cap1(0); // open the default camera | |
cv::VideoCapture cap1(0); // open the first camera | |
cv::VideoCapture cap2(1); // open the second camera | |
if(!cap1.isOpened()) // check if we succeeded | |
return -1; | |
if(!cap2.isOpened()) // check if we succeeded | |
return -1; | |
for(;;) | |
{ | |
cv::Mat frame1, frame2; | |
cap1 >> frame1; // get a new frame from camera | |
cap2 >> frame2; // get a new frame from camera | |
cv::Mat display (frame1.size().height, frame1.size().width + frame2.size().width, CV_8UC3) ; | |
cv::Mat left(display, cv::Rect(0, 0, frame1.size().width, frame1.size().height)); | |
frame1.copyTo(left); | |
cv::Mat right(display, cv::Rect(frame1.size().width, 0, frame2.size().width, frame2.size().height)); | |
frame2.copyTo(right); | |
cv::imshow("Display", display); | |
int key = cv::waitKey(1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment