Refresh webcamlist in app designer
1 回表示 (過去 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
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.
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!