When you finish using your image acquisition objects, use the
to remove them from memory. After deleting them, clear the variables
that reference the objects from the MATLAB® workspace
by using the
Note When you delete a video input object, all the video source objects associated with the video input object are also deleted.
To illustrate, this example creates several video input objects and then deletes them.
image acquisition objects — This example creates
several video input objects for a single webcam image acquisition
device, specifying several different video formats. To run this example
on your system, use the
imaqhwinfo function to
get the object constructor for your image acquisition device and substitute
that syntax for the following code.
vid = videoinput('winvideo',1); vid2 = videoinput('winvideo',1,'RGB24_176x144'); vid3 = videoinput('winvideo',1,'YV12_352x288');
Clean up — Always remove image acquisition objects from memory, and the variables that reference them, when you no longer need them.
You can delete image acquisition objects one at a time, using the delete function.
You can also delete all the video input
objects that currently exist in memory in one call to
imaqfind function. The
returns an array of all the video input objects in memory.
imaqfind Video Input Object Array: Index: Type: Name: 1 videoinput RGB555_128x96-winvideo-1 2 videoinput RGB24_176x144-winvideo-1 3 videoinput YV12_352x288-winvideo-1
Nest a call to the
delete function to delete all these
objects from memory.
Note that the variables associated with the objects remain in the workspace.
whos Name Size Bytes Class vid 1x1 1120 videoinput object vid2 1x1 1120 videoinput object vid3 1x1 1120 videoinput object vids 1x3 1280 videoinput object
These variables are not valid image acquisition objects.
isvalid(vid) ans = 0
To remove these variables from the workspace, use the