Borrar filtros
Borrar filtros

How Input Web Cam Real Time Live Video Record

1 visualización (últimos 30 días)
SAMEER ahamed
SAMEER ahamed el 8 de Feb. de 2014
Comentada: Walter Roberson el 11 de Feb. de 2014
Hi,
I have trying to record real time video from input web cam video.Below step's i have followed ,but i cannot get proper?
Step 1 : When I have Click Button Start Button ,input web cam on
if true
faceDetector = vision.CascadeObjectDetector('FrontalFaceCART');
if strcmp(get(handles.captureImage,'String'),'Start Training')
set(handles.captureImage,'String','Stop Training');
vid = videoinput('winvideo');
set(vid,'FramesPerTrigger',1);
set(vid,'TriggerRepeat',Inf);
set(vid,'ReturnedColorSpace','rgb');
triggerconfig(vid, 'Manual');
start(vid);
trigger(vid);
I = (getdata(vid,1,'uint8'));
else
set(handles.captureImage,'String','Start Training')
stop(vid);
delete(vid);
end
end
Step 2 : When i have click start Button i am getting error like : *Image acquisition object OBJ is an invalid object.Error in GUI>captureImage_Callback (line 400)
stop(vid);*
Step 3:I got Another Error like : *Reference to a cleared variable I.
Error in GUI>captureImage_Callback (line 384)
imshow(I);*
Note : Where i have made mistaken in Start /Stop record Button.
Thanks

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Feb. de 2014
The video object is local to the function you have it in, and is getting destroyed when the callback returns. You need to retain the object somehow, such as storing it in the handles structure.
  6 comentarios
SAMEER ahamed
SAMEER ahamed el 11 de Feb. de 2014
Editada: Walter Roberson el 11 de Feb. de 2014
ok,now below code i have added both function's (Start and Stop Button's), Error Showing Reference to non-existent field 'upper_distance'.
function pbStart_Callback(hObject, eventdata, handles)
vid = videoinput('winvideo');
handles.vid = vid;
set(handles.vid,'FramesPerTrigger',1);
set(handles.vid,'TriggerRepeat',Inf);
triggerconfig(handles.vid, 'Manual');
guidata(hObject, handles);
start(handles.vid);
trigger(handles.vid);
I = (getdata(handles.vid,1,'uint8'));
handles.upper_distance = hypot(blobCentroid_frames(1), topRowY_frames) ;
guidata(hObject, handles);
Stop Button below Code
% --- Executes on button press in pbStop.
function pbStop_Callback(hObject, eventdata, handles)
set(handles.pbStart,'enable','on');
set(handles.pbStop,'enable','off');
disp(handles.upper_distance); %Here Error Showing like *Reference to non-existent field 'upper_distance'.*
guidata(hObject, handles);
Walter Roberson
Walter Roberson el 11 de Feb. de 2014
I am not sure. Could you add disp() statements in the Start callback, one per line after the first guidata(), to be sure that the lines are being executed?
start(handles.vid);
disp('did start');
trigger(handles.vid);
disp('did trigger');
I = (getdata(handles.vid,1,'uint8'));
disp('got 1 frame');
handles.upper_distance = hypot(blobCentroid_frames(1), topRowY_frames) ;
disp('calculated upper distance');
guidata(hObject, handles);
disp('saved guidata');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by