Refresh webcamlist in app designer
Mostra commenti meno recenti
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
function startupFcn(app)
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';
end
end
I use only 3 Lamps in this code because i only have 3 differents cameras to test it.

Thanks in advance for the answers.
Risposte (1)
Srijith Vijay
il 18 Lug 2020
Modificato: Srijith Vijay
il 18 Lug 2020
0 voti
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.
Categorie
Scopri di più su Develop Apps Using App Designer in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!