How to preview live video in App Designer using videoinput and preview?

71 views (last 30 days)
I am trying to capture live feed from a camera in App Designer. At the command window I can use "videoinput" and preview to do this, but it's not working in my app. How do I do this?
vid = videoinput('winvideo',1);

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Nov 2018
In order to preview the video in your uiaxes, you can create an image and preview the video on that image:
% Image acquisition
vid = videoinput('winvideo',1);
% Create blank image
hImage = image(app.UIAxes,zeros(720,1280,3)); %If image resolution is 1280x720
% These lines set proper aspect ratio
app.UIAxes.XLim = [0,1280];
app.UIAxes.YLim = [0,720];
app.UIAxes.XTick = [];
app.UIAxes.YTick = [];
% Preview the image
Navid Ghorbanian
Navid Ghorbanian on 16 Mar 2021
You need to use the 'Axis' component instead of 'Image' component from the library for this method to work.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!