Events in preview function in App Designer

5 次查看(过去 30 天)
Hello, I want create App Designer app which preview live camera image. There is function called preview which create new window with live data Link. There is a lot of questions (with solutions) how use this function to display live camera image in application window (1, 2). However, I would also like to display information that is contained in the original preview window such as Resolution, Status and Timestamp. The nice tutorial was made but it only applies to GUIDE or Programmatic Workflow (Link). Does anyone have any idea how to do this in App Designer ?

回答(1 个)

Shivangi Gupta
Shivangi Gupta 2021-8-27
编辑:Shivangi Gupta 2021-8-27
While calling the custom preview function, use the prefix 'app.'. Also, while defining the 'vid' variable, define it as a property. This ensures that it can be accessed anywhere.
app.vid = videoinput('winvideo',1);
% Create blank image
hImage = image(app.UIAxes,zeros(720,1280,3)); %If image resolution is 1280x720
pause(2)
% These lines set proper aspect ratio
app.UIAxes.XLim = [0,1280];
app.UIAxes.YLim = [0,720];
app.UIAxes.XTick = [];
app.UIAxes.YTick = [];
pbaspect(app.UIAxes,[1280,720,1])
preview(app.vid,hImage)
% Set up the update preview window function.
setappdata(hImage, 'UpdatePreviewWindowFcn', @app.preview_fcn);
% Make handle to text label available to update function.
setappdata(hImage,'HandleToTimestampLabel',app.TimeStamp);
Refer to the original answer for further reference:
Details about the custom function “preview_fcn” can be found out from the link below:

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by