Image Acquisition Toolobox : Why Stop(vid) is so slow?

1 view (last 30 days)
Hi Everyone,
I am currently using the Image Acquisition Toolbox to acquire data (from a camera PhotonFocus using a Matrox Interface).
In order to change acquisition parameters, I need to start and stop the videoinput quite often, but I found out that the function stop(vid) is super slow (about 5 seconds every time.)
To be more specific, here are some of the parameters I use:
vid = videoinput('matrox',1,'fichier.dcf');
set(vid, 'TriggerRepeat', Inf);
triggerconfig(vid, 'Manual';)
set(vid, 'FramesPerTrigger', 1, 'LoggingMode', 'memory');
With these parameters, start(vid) executes fastly, but stop(vid) is slow.
What does not make sense to me is that, if I set my trigger to execute a finite number of times, then the videoinput stops "naturally" when all my triggers are executed. In this case, stopping the videoinput does not seem to take any time.
So, it seems to me that the video input can fastly(less than 0.1s) stop runnning for any of the following conditions (The requested number of frames is acquired, A run-time error occurs, or The object's Timeout value is reached), but becomes slow when I use stop(vid).
Does anyone have an idea why this stop function can be so slow?
Or, is there a way to avoid the use of stop(vid)?
Unfortunetaly I can't use a finite number of triggers, since I want to acquire images untill some event(which never occurs at the same time) happens. I also can't use other functions such as preview, because I need to change the data before displaying them.
Thanks a lot,
Olivier

Answers (2)

Sean de Wolski
Sean de Wolski on 21 Aug 2014
Have you profiled it to see if anything else happens when the video stops? A graphics update? A file-write, etc.?
doc profile

Thouvenin Olivier
Thouvenin Olivier on 22 Aug 2014
Yes I did try to profile my code, and it appears that it is only the self Time of the stop function that lasts for several seconds.
When I look into the stop function to see which subfunction takes that long, it is only this line :
stop(uddObjects(i));
I finally took a look at the length of uddObjects but it seems to be 1.
May be, 5sec is the usual time it takes to stop any videoinput from running, but I don't understand why it requires so long?! Or why I have the feeling that it can stop quickly when the number of Triggers reaches its value.
Can anyone tell me if stop(vid) is also usually slow in his own programs? I expect the time of stop(vid) will depend on the framegrabber and the .dcf file, but if stop(vid) is always slow, it can still give me a clue!
Thanks!

Community Treasure Hunt

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

Start Hunting!