Info

This question is closed. Reopen it to edit or answer.

I get error when I closed the window before selected the stop button for live video

1 view (last 30 days)
I have the following code for live video:
function track_OpeningFcn(hObject, eventdata, handles, varargin)
movegui(hObject,'center')
imaqreset
vid = videoinput('winvideo',1);
handles.video = vid;
set(handles.video,'TimerPeriod', 0.05, ...
'TimerFcn',['if(~isempty(gco)),'...
'handles=guidata(gcf);'...
'image(getsnapshot(handles.video));'...
'set(handles.axes2,''ytick'',[],''xtick'',[]),'...
'else '...
'delete(imaqfind);'... % Clean up - delete any image acquisition objects
'end']);
triggerconfig(handles.video,'manual');
handles.video.FramesPerTrigger = Inf;
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
uiwait
function StartVideo_Callback(hObject, eventdata, handles)
vid = handles.video;
start (vid);
guidata(hObject, handles)
function StopVideo_Callback(hObject, eventdata, handles)
vid = handles.video;
stop (vid);
guidata(hObject, handles)
function track_CloseRequestFcn(hObject, eventdata, handles)
uiresume
delete(hObject)
delete (handles.video)
imaqreset
I get this error when I closed the window before selected the stop button:
Error using imaqdevice/getsnapshot (line 65)
Image acquisition object OBJ has been deleted. OBJ is now an invalid object.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!