Events in preview function in App Designer

5 views (last 30 days)
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 ?

Answers (1)

Shivangi Gupta
Shivangi Gupta on 27 Aug 2021
Edited: Shivangi Gupta on 27 Aug 2021
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:

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!