-
Notifications
You must be signed in to change notification settings - Fork 2
/
listarDispositivos.m
39 lines (36 loc) · 1.82 KB
/
listarDispositivos.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
adaptorName = 'winvideo';
deviceID = 1;
vidFormat = 'YUY2_640x360';
tag = '';
% Search for existing video input objects.
existingObjs1 = imaqfind('DeviceID', deviceID, 'VideoFormat', vidFormat, 'Tag', tag);
% There are existing video input objects in memory that have the same
% DeviceID, VideoFormat, and Tag property values as the object we are
% recreating. If any of those objects contains the same AdaptorName
% value as the object being recreated, then we will reuse the object.
% If more than one existing video input object contains that
% AdaptorName value, then the first object found will be reused. If
% there are no existing objects with the AdaptorName value, then the
% video input object will be created.
% Query through each existing object and check that their adaptor name
% matches the adaptor name of the object being recreated.
for i = 1:length(existingObjs1)
% Get the object's device information.
objhwinfo = imaqhwinfo(existingObjs1{i});
disp(objhwinfo.AdaptorName);
% Compare the object's AdaptorName value with the AdaptorName value
% being recreated.
if strcmp(objhwinfo.AdaptorName, adaptorName)
% The existing object has the same AdaptorName value as the
% object being recreated. So reuse the object.
vidObj1 = existingObjs1{i};
% There is no need to check the rest of existing objects.
% Break out of FOR loop.
break;
elseif(i == length(existingObjs1))
% We have queried through all existing objects and no
% AdaptorName values matches the AdaptorName value of the
% object being recreated. So the object must be created.
vidObj1 = videoinput(adaptorName, deviceID, vidFormat);
end %if
end %for