Events in preview function in App Designer

조회 수: 5 (최근 30일)
Przemyslaw Gontar
Przemyslaw Gontar 2019년 9월 4일
편집: Shivangi Gupta 2021년 8월 27일
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