Prev: Getting X & Y coordinates from the peak of a graph.
Next: bp training algorithm with dynamic threshod in the output layer
From: Ashar on 24 Apr 2010 06:52 Arghh... so frustating... anybody knows how to use close(vid) ? I'm Matlab GUI user but I've problem using close(vid) in push_button_2 callback function, say... my GUI has two push button and one axis to display image. i use push_button_1 to set video using image acquisition toolbox, and display it into axis. but when i press push_button_2 to stop video input the error occur. matlab says Reference to non-existent field 'vid'. i tried close(handles.vid) instead of close(vid), but it doesnt work. here is my simple code : %%%%%% PUSH_BUTTON_1_CALL_BACK_FUNCTION %%%%%%%% function pushbutton1_Callback(hObject, eventdata, handles) handles.vid = videoinput('winvideo',1,'RGB24_320x240'); set(handles.vid,'TriggerRepeat',inf); triggerconfig(handles.vid,'manual'); set(handles.vid,'FramesPerTrigger',1); start(handles.vid); while (handles.vid.FramesAcquired<=50) trigger(handles.vid); data_image=getdata(handles.vid,1); handles.axes1,imshow(data_image); flushdata(vid); end stop(handles.vid); %%%%%% PUSH_BUTTON_2_CALL_BACK_FUNCTION %%%%%%%% function pushbutton2_Callback(hObject, eventdata, handles) stop(handles.vid); the close(vid) only works when i use it in the same call_back_function where start(vid) is exist. please helpme... thanks for reading my post.
From: Ashish Uthama on 26 Apr 2010 08:04 On Sat, 24 Apr 2010 05:12:06 -0300, Ashar <zero_fauzi(a)yahoo.com> wrote: > Arghh... so frustating... > > anybody knows how to use close(vid) ? I'm Matlab GUI user but I've > problem using close(vid) in push_button_2 callback function, say... my > GUI has two push button and one axis to display image. i use > push_button_1 to set video using image acquisition toolbox, and display > it into axis. but when i press push_button_2 to stop video input the > error occur. matlab says Reference to non-existent field 'vid'. i tried > close(handles.vid) instead of close(vid), but it doesnt work. here is my > simple code : > > > %%%%%% PUSH_BUTTON_1_CALL_BACK_FUNCTION %%%%%%%% > function pushbutton1_Callback(hObject, eventdata, handles) > handles.vid = videoinput('winvideo',1,'RGB24_320x240'); > set(handles.vid,'TriggerRepeat',inf); > triggerconfig(handles.vid,'manual'); > set(handles.vid,'FramesPerTrigger',1); > start(handles.vid); > while (handles.vid.FramesAcquired<=50) > trigger(handles.vid); > data_image=getdata(handles.vid,1); > handles.axes1,imshow(data_image); > flushdata(vid); > end > stop(handles.vid); > > > %%%%%% PUSH_BUTTON_2_CALL_BACK_FUNCTION %%%%%%%% > function pushbutton2_Callback(hObject, eventdata, handles) > stop(handles.vid); > > the close(vid) only works when i use it in the same call_back_function > where start(vid) is exist. please helpme... thanks for reading my post. Dont you have to use GUIDATA to store the updated handles value? http://www.mathworks.com/access/helpdesk/help/techdoc/ref/guidata.html
From: Ashar on 28 Apr 2010 02:02
problem solved just use Global variabel... ex : function button_1 global vid vid=... function button_2 global vid anyway, thans all |