Contact Us
Sear ch
Log In
Solutions
Academia
Support
User Community
Events
Company
Documentation Center
Trial Software Product Updates Share
Sear ch
Acquire Multiple Frames Acommon task is to repeatedly acquire a single image, process it, and then store the result. To do this, GETSNAPSHOT can be called in a loop. for i = 1:5 snapshot = getsnapshot(vidobj); imagesc(snapshot); end
converted by Web2PDFConvert.com
Timing Implications The GETSNAPSHOT function performs a lot of work when it is called. It must connect to the device, configure it, start the acquisition, acquire one frame, stop the acquisition, and then close the device. This means that the acquisition of one frame can take significantly longer than would be expected based on the frame rate of the camera. To illustrate this, call GETSNAPSHOT in a loop. % Measure the time to acquire 20 frames. tic for i = 1:20 snapshot = getsnapshot(vidobj); end elapsedTime = toc % Compute the time per frame and effective frame rate. timePerFrame = elapsedTime/20 effectiveFrameRate = 1/timePerFrame elapsedTime = 21.2434
timePerFrame = 1.0622
effectiveFrameRate = 0.9415 The next example illustrates a more efficient way to perform the loop. Using Manual Trigger Mode You can avoid the overhead of GETSNAPSHOT described in the previous setting by using the manual triggering mode of the videoinput object. Manual triggering mode allows the toolbox to connect to and configure the device a single time without logging data to memory. This means that frames can be returned to MATLAB with less of a delay. % Configure the object for manual trigger mode. triggerconfig(vidobj, 'manual'); % Now that the device is configured for manual triggering, call START. % This will cause the device to send data back to MATLAB, but will not log % frames to memory at this point. start(vidobj) % Measure the time to acquire 20 frames. tic for i = 1:20 snapshot = getsnapshot(vidobj); end elapsedTime = toc % Compute the time per frame and effective frame rate. timePerFrame = elapsedTime/20 effectiveFrameRate = 1/timePerFrame
converted by Web2PDFConvert.com
% Call the STOP function to stop the device. stop(vidobj) elapsedTime = 1.4811
timePerFrame = 0.0741
effectiveFrameRate = 13.5031 You can see that the elapsed time using manual triggering is much smaller than the previous example. Cleanup Once the video input object is no longer needed, delete the associated variable. delete(vidobj) See also IMAQHELP, VIDEOINPUT, IMAQDEVICE/GETSNAPSHOT, IMAQDEVICE/START, IMAQDEVICE/STOP IMAQDEVICE/TRIGGERCONFIG. Was this topic helpful? Yes
No
Site Help
Patents
Trademarks
Privacy Policy
converted by Web2PDFConvert.com