Simultaneous video recording for multiple cameras

23 views (last 30 days)
I am currently working on video recording with two cameras and I'm trying to figure out how to start and stop the recording for two cameras at the same time. I'm using the getsnapshots and videoWriter to get the frames and to store the video file. However, with for loop they always have a delay between each other, and it compromises the frame rate of the cameras also. I tried with parfor but it never writes to the video file and seems to have some internal problem. I also tried the disklogger, but only one video would be write properly to the file and the other basically contains nothing. I would really appreciate for any suggestions or short example code to explain how parallel computing would work for running multiple cameras! P.S. I am using imaging source Dmm 42BUC03-ML cameras in case the information would be helpful. It is an OEM camera.

Answers (2)

Walter Roberson
Walter Roberson on 2 Mar 2016
It appears that those devices support external trigger. It looks plausible that you could configure them for logging to memory, configure the trigger condition as external, configure a number of frames per trigger. And then use something on the host that generates a trigger to be received by both cameras.

Rebecca Ijekah
Rebecca Ijekah on 19 Apr 2018
Joy and/or Walter, Did you ever find a solution for simultaneously recording from multiple cameras using matlab to start/stop the video recording? Is there a way we could connect without posting our emails on a public web page so that we may email each other code? I would like to start with simply recording from one camera, eventual I would like to record from 2-4 webcams simultaneously. I would appreaciate any help! Thanks! p.s. Currently I have 2 Logitech webcams (HD 1080P, c920) I also have a webcam that records in infrared.
  5 Comments
Walter Roberson
Walter Roberson on 15 Sep 2022
In order to record from two or more video cameras simultaneously one of the following needs to be true:
  • the cameras need to have a common external trigger; or
  • one of the cameras needs to be able to generate a trigger and the others need to be slaved to it; or
  • the signal from the video cameras needs to be feeding into a framebuffer designed to handle multiple signals (this would be for continuous sensor cameras that send the data out over lines but do not have snapshot logic or image transfer logic -- for example some older style CCTV cameras); or
  • for USB cameras, the cameras need to be controlled by a data capture board or device that has multiple USB controllers so that it can send out simultaneous capture requests; or
  • for ethernet cameras, the cameras need to be able to listen for broadcast traffic so that you can send out a "snapshot" request to them all simultaneously. For high frame rates this might not be good enough as latencies can vary over devices and distance. If you are using an unmanaged ethernet switch, then it will not necessarily "cut through" the broadcast to all ports simultaneously (which is also true for lower-end managed switches, but you can find higher end switches and routers that are designed for simultaneous cut-through of broadcasts.)
Notice that this list completely excludes the possibility of using multiple USB cameras plugged into the same MATLAB host, even if the cameras are connected to different USB controllers: you will not be able to achieve frame synchronization for such a situation.
If I understand correctly, the Image Acquisition Toolbox is designed to be able to manage two USB camera streams (but not synchronized), and that if you have more than two USB cameras that it might fail.
USB cameras are not a good choice for frame synchronization -- not unless they are built with synchronization in mind.
Ethernet can have a considerably higher bandwidth and lower latency than USB, so if you need frame synchornization then Ethernet (gigabit) cameras are a better choice -- you might still not be able to truly synchornize but you will get closer than with USB cameras.
If you use the Data Acquisition Toolbox and use something like an NIDAQ chassis and appropriate devices, then you can get something that might not be frame synchronized, but in which each frame is timestamped.
Because that is a quite different issue than synchronized frames: if you have timestamped frames then even though you might not receive corresponding frames at the same time (and frames might sometimes go missing), you can compare timestamps to find the closest match and do post-synchronization (and, if necessary, interpolate between multiple frames in order to get an estimated synchronized frame.)
Juraj Janura
Juraj Janura on 17 Sep 2022
Dear Walter, Thanks a lot for your answer, this new info are very helpful fo me.Thanks again.

Sign in to comment.

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!