How to put two videos side by side in a single frame?
I'm using python, and I don't know how to put two video streams side by side in a single frame. Please help. Thank you.
you can try something like that, check the code below (it is in C++ but I do not think that it would be hard to port it in python):
// I consider that you have two frames, frame1 and frame2 which have similar dimensions
Mat canvas = Mat::zeros(frame1.rows, frame1.cols*2+10, frame1.type());
frame1.copyTo(canvas(Range::all(), Range(0, frame2.cols)));
frame2.copyTo(canvas(Range::all(), Range(frame2.cols+10, frame2.cols*2+10)));
// if it is too big to fit on the screen, then scale it down by 2, hopefully it'll fit :-)
if(canvas.cols > 1920)
{
resize(canvas, canvas, Size(canvas.cols/2, canvas.rows/2));
}
imshow("canvas", canvas);
Asked: 2015-03-24 15:34:08 -0600
Seen: 4,549 times
Last updated: Mar 24 '15