Hi, I tried to create an app simply to display capture from a webcam. The main functions are like below.
properties (Access = private) KeepRunning = 1; cam = webcam('USB Video Device'); end methods (Access = private) % Code that executes after component creation
function startupFcn(app) app.cam.Resolution = '640x480'; while 1 rgbImage = snapshot(app.cam); imshow(rgbImage,'Parent',app.UIAxes); drawnow; end end % Close request function: UIFigure
function UIFigureCloseRequest(app, event) delete(app.cam) delete(app) end end
Everything works fine; however, as I close the GUI (using X button), this error popped up. Any ideas?
Invalid or deleted object.Error in app_test/startupFcn (line 23) rgbImage = snapshot(app.cam);Error in app_test (line 84) runStartupFcn(app, @startupFcn)
Best Answer