2015-01-01 1 views
1

Привет Я создаю графический интерфейс Matlab, который позволяет веб-камере распознавать лицо человека после выполнения функции Face Tracking. Тем не менее, я могу только обнаружить лицо, но он не отслеживает лицо.Функция отслеживания лица GUI Matlab

% --- Executes on button press in Tracking. 
function Tracking_Callback(hObject, eventdata, handles) 
% hObject handle to pushbutton9 (see GCBO) 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles structure with handles and user data (see GUIDATA) 
% hObject handle to startStopCamera (see GCBO) 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles structure with handles and user data (see GUIDATA) 

% Create a cascade detector object. 
faceDetector = vision.CascadeObjectDetector(); 

% Read a video frame and run the detector. 
axes(handles.cameraAxes);  
frame = getsnapshot(handles.vid); 
bbox = step(faceDetector,frame); 


% Draw the bounding box around the face. 
rectangle('Position',bbox(1,:),'LineWidth',2,'EdgeColor',[1 1 0]); 

%Track the face over successive video frames until the video is finished. 
while ~isDone(handles.vid) 

% Extract the next video frame 
frame = getsnapshot(handles.vid); 
bbox = step(faceDetector,frame); 

% Insert a bounding box around the object being tracked 
rectangle('Position',bbox(1,:),'LineWidth',2,'EdgeColor',[1 1 0]); 


% Display the annotated video frame using the video player object 
getsnapshot(handles.vid); 

    end 

release(frame); 
release(handles.vid); 

Я использую панель инструментов Image Acquisition Toolbox и посетил несколько веб-сайтов, но, похоже, я не могу решить эту проблему.

Любая помощь очень ценится!

ответ

1
+0

Привет Я пробовал эти примеры, но моя программа не похоже на работу – Helen

+0

@Helen, эти примеры именно то, что вам нужно. Если вы точно понимаете, как они работают, вы должны иметь возможность адаптировать свой код для своего проекта. Также взгляните на этот пример: http://www.mathworks.com/matlabcentral/fileexchange/47105-detect-and-track-multiple-faces – Dima