Timeout error getting frame webcam in deploying standalone app by app designer

18 views (last 30 days)
Hi, please help.
I try to deploy an app compiled by matlab app designer 2022a to another PC. This app simply just open webcam in one ax, and one button, when it is pushed, it takes picture from camera to show in second ax.
it works perfectly on the PC, that I created the app. But on the PC (which was installed right runtime version) it shows this error when I try to open installed app:
Timeout occured while trying to get a frame from the webcam. Error in => OKELA.mlapp at line 91
Thanks a lot.
classdef OKELA < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
ZapnoutkameruButton matlab.ui.control.Button
UIAxes2 matlab.ui.control.UIAxes
UIAxes matlab.ui.control.UIAxes
end
properties (Access = public)
cam % Description
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.UIAxes2.Visible = "off";
evalin("base","clear cam");
app.cam = webcam('USB2.0 Camera');
frame = app.cam.snapshot;
im = image(app.UIAxes,zeros(size(frame),'uint8'));
axis(app.UIAxes,'image');
preview(app.cam,im);
end
% Button pushed function: ZapnoutkameruButton
function ZapnoutkameruButtonPushed(app, event)
img = app.cam.snapshot;
image(app.UIAxes2,img);
app.UIAxes2.Visible = 'off';
axis(app.UIAxes2,'image');
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 = 'MATLAB App';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'live')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [16 129 284 336];
% Create UIAxes2
app.UIAxes2 = uiaxes(app.UIFigure);
title(app.UIAxes2, 'obraz')
xlabel(app.UIAxes2, 'X')
ylabel(app.UIAxes2, 'Y')
zlabel(app.UIAxes2, 'Z')
app.UIAxes2.Position = [340 129 281 335];
% Create ZapnoutkameruButton
app.ZapnoutkameruButton = uibutton(app.UIFigure, 'push');
app.ZapnoutkameruButton.ButtonPushedFcn = createCallbackFcn(app, @ZapnoutkameruButtonPushed, true);
app.ZapnoutkameruButton.Position = [258 43 103 23];
app.ZapnoutkameruButton.Text = 'Zapnout kameru';
% 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 = OKELA
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
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
  5 Comments
Image Analyst
Image Analyst on 5 Feb 2023
If you have the Image Acquisition Toolbox you should be able to run imageAcquisitionExplorer and see something like this:
but you don't need the Image Acquisition Toolbox to use webcams. You just need to get the webcam add on from the Add-ons Explorer on the home tab of the tool ribbon.

Sign in to comment.

Answers (0)

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!