problem to stop a video capture
2 views (last 30 days)
Show older comments
Hi.
I'm using Matlab 2014a with IImage Acquisition Toolbox Version 4.7 (R2014a) 27-Dec-2013. I want to record video from 4 cameras, using a frame grabber (The Imagin Source DFG/MC4/PCIe).
My code is:
1.
vid1=videoentrada(1);
vid2=videoentrada(2);
vid3=videoentrada(3);
vid4=videoentrada(4);
function vid = videoentrada( n )
k=imaqhwinfo('tisimaq_r2013');
ans=k.DeviceInfo.SupportedFormats;
vid=videoinput('tisimaq_r2013',n,ans{1,127});
end
2.
inicia_video(vid1,mi_dir,1)
inicia_video(vid2,mi_dir,2)
inicia_video(vid3,mi_dir,3)
inicia_video(vid4,mi_dir,4)
function inicia_video(vid,nombre_dir,n)%,handle)
vid.FramesPerTrigger = Inf
vid.LoggingMode = 'disk';
mi_archivo=[nombre_dir '/' 'video' num2str(n) '.avi'];
writerObj = VideoWriter(mi_archivo);
vid.LoggingMode='Disk';
vid.DiskLogger = writerObj;
triggerconfig(vid,'manual');
start(vid);
end
3.
trigger(vid1);
trigger(vid2);
trigger(vid3);
trigger(vid4);
4. (by pressing a button)
stop(vid1);
stop(vid2);
stop(vid3);
stop(vid4);
The program "hangs" when executing stop(vid1).
There is no problem when using only two cameras. When using three cameras, the program hangs for some seconds, and then finishes well.
Any hint? Thanks a lot.
0 Comments
Answers (1)
Rohit Kudva
on 19 Oct 2015
Hi Benigno,
One possible issue may be memory limitations as you are trying to grab frames from multiple camera's at the same time. You can try increasing the Java heap space for MATLAB. Following is the link which will guide you on how to increase heap space:
Another possible reason can be that when logging large amounts of data to disk, disk writing occasionally lags behind the acquisition. So when the 'stop' command is issued, the image acquisition stops by setting the 'Running' property of the video input object to 'Off' but the 'Logging' property is set to 'Off' only once all the frames have been logged to disk. To determine whether all frames are written to disk, you can optionally use the DiskLoggerFrameCount property.
while (vidobj.FramesAcquired ~= vidobj.DiskLoggerFrameCount)
pause(.1)
end
So Ideally you may want to to execute
>> stop(vidobj);
Only after the above 'while' loop is exited.
I hope this resolves your issue
Regards,
Rohit
See Also
Categories
Find more on National Instruments Frame Grabbers 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!