Managing Video Input Objects
This example shows how to find video input objects and remove video input objects from memory.
Finding Video Input Objects in Memory
To find video input objects in memory, use the IMAQFIND function. IMAQFIND returns an array of video input objects.
objects = imaqfind
objects = []
% Create video input objects. vidobj1 = videoinput('matrox', 1, 'M_CCIR'); vidobj2 = videoinput('matrox', 1, 'M_PAL_RGB'); vidobj3 = videoinput('matrox', 1, 'M_NTSC_RGB'); % Find all valid objects. objects = imaqfind
Video Input Object Array: Index: Type: Name: 1 videoinput M_CCIR-matrox-1 2 videoinput M_PAL_RGB-matrox-1 3 videoinput M_NTSC_RGB-matrox-1
Removing Objects from Memory
To delete a video input object from memory, use the DELETE function with the object.
% Delete the first object in the array.
delete(objects(1))
Find all remaining valid objects.
objects = imaqfind
Video Input Object Array: Index: Type: Name: 1 videoinput M_PAL_RGB-matrox-1 2 videoinput M_NTSC_RGB-matrox-1
Using the DELETE function with the object will remove the object from memory but not from the MATLAB® workspace. To remove an object from the MATLAB workspace use the CLEAR function. To see what objects are in the MATLAB workspace, use the WHOS function.
% Display the current workspace.
whos
Name Size Bytes Class objects 1x2 1200 videoinput object vidobj1 1x1 1060 videoinput object vidobj2 1x1 1060 videoinput object vidobj3 1x1 1060 videoinput object Grand total is 185 elements using 4380 bytes
Since an object was deleted, it is no longer valid.
vidobj1
Invalid Image Acquisition object. This object is not associated with any hardware and should be removed from your workspace using CLEAR.
Clear the associated variable.
clear vidobj1
Display the current workspace.
whos
Name Size Bytes Class objects 1x2 1200 videoinput object vidobj2 1x1 1060 videoinput object vidobj3 1x1 1060 videoinput object Grand total is 142 elements using 3320 bytes
To remove all video input objects from memory and to reset the toolbox to its initial state, use the IMAQRESET function.
Note: Using the IMAQRESET function will only delete objects from memory, not clear them from the MATLAB workspace.
imaqreset
Verify no objects remain.
objects = imaqfind
objects = []
Variables associated with deleted objects still remain.
whos
Name Size Bytes Class objects 0x0 0 double array vidobj2 1x1 1060 videoinput object vidobj3 1x1 1060 videoinput object Grand total is 86 elements using 2120 bytes
Clear any remaining variables associated with deleted objects.
clear vidobj2 vidobj3