【发布时间】:2022-06-19 17:58:42
【问题描述】:
我在应用程序设计器中做一个界面,当我按下一个按钮(Empezar 按钮)时我打开我的网络摄像头,唯一的问题是我找不到如何停止我的网络摄像头的方法,它在循环,当我按下另一个按钮(停止按钮)时,我需要完成该循环,但是我尝试了很多东西,但似乎没有任何效果,我尝试使用 buttonpressfcn 不起作用,打开一个图,当它关闭视频停止的数字也不起作用,有什么想法吗?我知道如何在 GUIDE 中停止 vid,但我必须使用 App Designer,而且我认为这不一样:(
properties (Access = public)
UIFigure matlab.ui.Figure
StopButton matlab.ui.control.Button
EmpezarButton matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: EmpezarButton
function EmpezarButtonPushed(app, event)
% clear all;
micamara=webcam(1);
micamara.Resolution='640x360';
micamara.Brightness=10;
%ventana=app.StopButton.ButtonPushedFcn;
%while ishandle(ventana)
ventana=figure;
while ishandle(ventana)
img=snapshot(micamara);
imshow(img,'Parent',app.UIAxes);
end
end
% Button pushed function: StopButton
function StopButtonPushed(app, event)
global ventana;
ventana=1;
end
end
【问题讨论】:
标签: matlab webcam matlab-app-designer