Ask Your Question
0

How to tile multiple live camera feeds in one window

asked 2016-05-30 05:01:56 -0600

lm35 gravatar image

updated 2016-05-30 09:28:50 -0600

pklab gravatar image

I have live feeds from four GigE cameras. Is it possible to display all the four feeds in a single window.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-05-30 09:20:25 -0600

pklab gravatar image

it's possible of course

Suppose you are grabbing in cv::Mat m1,m2,m3,m4; that have same size and type

//define the tiled image so that it can contains 4 images
Mat tile
tile = Mat(2*m1.size(),m1.type());

//define 4 ROI where the single images will be copied to
Rect r1,r2,r3,r4;
r1 = Rect(0,0,m1.size());             // top left
r2 = Rect(m1.cols,0,m1.size());       // top right
r3 = Rect(0,m1.rows,m1.size());       // bottom left
r4 = Rect(m1.cols,m1.rows,m1.size()); // bottom right

// Transfer the image into tiled one
m1.copyTo(tile(r1));    m2.copyTo(tile(r2));
m3.copyTo(tile(r3));    m4.copyTo(tile(r4));

cv::imshow("Tiled images", tile);
edit flag offensive delete link more

Comments

Camera feed is live '.avi' video files.I am accessing each cameras one by one. So whether tiling is possible in this scenario.

lm35 gravatar imagelm35 ( 2016-05-31 03:29:21 -0600 )edit

Camera feed is live '.avi' video files means you have something like this:

cv::VideoCapture cam1("file1.avi");
...
cv::VideoCapture cam4("file4.avi");

than you easily can do

cam1 >> m1;
...
cam4 >> m4;

than use the code as is in the answer

pklab gravatar imagepklab ( 2016-05-31 05:50:57 -0600 )edit

OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/valuser/opencv-2.4.13/modules/core/src/matrix.cpp, line 323 terminate called after throwing an instance of 'cv::Exception' what(): /home/valuser/opencv-2.4.13/modules/core/src/matrix.cpp:323: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat Got above error for belo tile setting. (img size = 700x400) r1 = Rect(0,0,2700, 2400) r2 = Rect(original_resized.cols-1,0,2700, 2400);
r3 = Rect(0,original_resized.rows-1,2700, 2400); r4 = Rect(original_resized.cols-1,original_resized.rows-1,2700, 2400

lm35 gravatar imagelm35 ( 2016-11-14 03:19:21 -0600 )edit

@lm35 you are using (wrong) number instead of variables. m1.size() and others are not placeholders!!! And if you like numbers you should use 2*700 and not 2700

pklab gravatar imagepklab ( 2016-11-15 12:44:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-05-30 05:01:56 -0600

Seen: 1,032 times

Last updated: May 30 '16