User`s guide

6 Working with Acquired Image Data
7 Clean up Always rem ove image acquisition objects from mem ory, and
the variables that re ference them, when you n o longer need them.
delete(vid)
clear vid
Bringing a Single Frame into the Workspace
To brin g a sin gle frame of image d a ta into the MATLAB workspace, use the
getsnapshot function. You can call the getsnap shot function at any time
after object creation.
Thisexampleillustrateshowsimpleitistousethe
getsnapshot function.
1 Create an im age acquisition object Th i s example creates a video
input object for a Matrox device. To run this example on your system,
use the
imaqhwinfo function to get the object constructor for your image
acquisition device a nd substitute that syntax for the following code.
vid = videoinput('mat rox',1);
2 Bring a frame into the workspace —Callthegetsnapshot function to
bringaframeintotheworkspace. Notethatyoudonotneedtostartthe
video input object before calling the
getsnapshot function.
frame = getsnapshot(v id);
The getsnapshot function returns an image of thesamewidthandheight
as spe cified by the
ROIPosition property and the same number of bands as
specified by the
NumberOfBands property. In this example, the video format
of the data is RGB so the value of the
NumberOfBands property is 3.
whos
Name Size Bytes Class
frame 96x128x3 36864 uint8 ar ray
vid 1x1 1060 videoinput object
6-10