Ask Your Question

How to put two videos side by side in a single frame?

asked 2015-03-24 15:34:08 -0500

shideh gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-03-24 17:41:29 -0500

theodore gravatar image

updated 2015-03-24 17:45:07 -0500

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);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-03-24 15:34:08 -0500

Seen: 2,497 times

Last updated: Mar 24 '15