Refresh webcamlist in app designer
조회 수: 3 (최근 30일)
I try to create a little code to acquire all cameras devices connected to my computer. To assure that the camera is plug in a lamp light up in yellow, if not the lamp is red.
I try this in the start up fonction in app designer but my problem is that the code execute well at the start but no refresh seems to appears when i unplug a camera.
So my question is : how can i have a continous refresh of that little code in app designer ?
Here is my code :
% Code that executes after component creation
x = string(webcamlist); % x get back all camera devices
[Rangenumb,~]= size(x); % Rangenumb get the number of devices
lamp = [app.Lamp_1;app.Lamp_2;app.Lamp_3]; % lamp get all UILamp in a matrix
for ii = 1:Rangenumb % the for loop turn on in yellow as many lamp as there is camera devices
lamp(ii).Color = 'yellow';
I use only 3 Lamps in this code because i only have 3 differents cameras to test it.
Thanks in advance for the answers.
Srijith Vijay 2020년 7월 18일
편집: Srijith Vijay 2020년 7월 18일
You could create a function (say refreshWebcam) and use this as the callback function for a MATLAB timer.
Start the timer in the startupFcn of the app and this should continuously keep checking for any new webcams connected, every 't' seconds. 't' being the timer period.