Miroslav Snopko
Miroslav Snopko

Reputation: 55

Creating mosaic of camera feeds in opencv without significant delay

Im working on project with opencv and c++. Version of Opencv is 3.1. HW setup is Nvidia gt460 and Intel i7 3820, 64Gb ram. Im trying to achieve multiple camera setup where all camera feeds will be merged in one big mosaic. In early stages maybe 4x4 later even bigger. After that I will be analyzing this mosaic and tracking multiple objects.

The problem is that when I create camera feed with capture command in Opencv and then store it to matrix, analyze it and show it. There's big FPS issue already with two camera feeds. I have tested three USB feeds as well as multiple UDP or RTSP streams. When using USB, delay is not the biggest problem but FPS are something like spliting between feeds. And using stream method is giving me low FPS and high delay (around 15 seconds). I also realized there is different delay between camera feeds even if I have cameras pointed on the same thing.

Is there anybody, who could help me or solved similiar problem? Is it problem of Opencv that it cannot analyze more live feeds simultaneously?

Heres my merging code:

    merged_frame = Mat(Size(1280, 960), CV_8UC3);

    roi = Mat(merged_frame, Rect(0, 0, 640, 480));
    cameraFeed.copyTo(roi);
    roi = Mat(merged_frame, Rect(640, 0, 640, 480));
    cameraFeed2.copyTo(roi);
    roi = Mat(merged_frame, Rect(0, 480, 640, 480));
    cameraFeed3.copyTo(roi);
    roi = Mat(merged_frame, Rect(640, 480, 640, 480));
    cameraFeed4.copyTo(roi);

Upvotes: 0

Views: 259

Answers (1)

Axel B.
Axel B.

Reputation: 131

There exists two functions hconcat and vconcat that are not in the documentation.

You can see an example of their use (which is quite easy if all your camera feeds provide frames that have the same resolution) here.

This will probably ask you to create temporary Mat objects to store intermediate results, but I think it's a more intuitive way to create a mosaic of frames.

Upvotes: 1

Related Questions