This video shows the steps to get the video from webcam and live stream on an axis in MATLAB App Designer.
Please note, to make the webcam work you may have to install the MATLAB Add on package for USB webcam from Add on explorer. Steps are shown in the YouTube video.
The interface image:

The script to do this in MATLAB is simple and is copied below:
classdef WebCam_Video_Streaming < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
StartButton matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
end
properties (Access = private)
cam; % Description
end% Callbacks that handle component events
methods (Access = private)% Button pushed function: StartButton
function StartButtonPushed(app, event)
app.cam = webcam;
frame = snapshot(app.cam);
im = image(app.UIAxes, zeros(size(frame),’uint8′));
axis(app.UIAxes,’image’);preview(app.cam,im);
% pause;
end
end% Component initialization
methods (Access = private)% Create UIFigure and components
function createComponents(app)% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘UI Figure’;% Create StartButton
app.StartButton = uibutton(app.UIFigure, ‘push’);
app.StartButton.ButtonPushedFcn = createCallbackFcn(app, @StartButtonPushed, true);
app.StartButton.Position = [271 430 100 22];
app.StartButton.Text = ‘Start’;% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, ‘Title’)
xlabel(app.UIAxes, ‘X’)
ylabel(app.UIAxes, ‘Y’)
app.UIAxes.Position = [51 35 511 363];% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end% App creation and deletion
methods (Access = public)% Construct app
function app = WebCam_Video_Streaming% Create UIFigure and components
createComponents(app)% Register the app with App Designer
registerApp(app, app.UIFigure)if nargout == 0
clear app
end
end% Code that executes before app deletion
function delete(app)% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
That is the best weblog for anybody who needs to seek out out about this topic. You notice so much its virtually arduous to argue with you (not that I truly would need…HaHa). You positively put a new spin on a topic thats been written about for years. Nice stuff, simply nice!
Thanks Chelsea 🙂
some really fantastic articles on this website , appreciate it for contribution.
Thanks Zachary 🙂
I enjoy your writing style truly enjoying this web site.
Thanks 🙂
I like this website very much so much great information.
Thanks Catherin 🙂