Events in preview function in App Designer

13 visualizzazioni (ultimi 30 giorni)
Przemyslaw Gontar
Przemyslaw Gontar il 4 Set 2019
Modificato: Shivangi Gupta il 27 Ago 2021
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 ?

Risposte (1)

Shivangi Gupta
Shivangi Gupta il 27 Ago 2021
Modificato: Shivangi Gupta il 27 Ago 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:

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by