1
嗨,我正在創建一個Matlab GUI,允許攝像頭一旦執行面部跟蹤功能就能夠檢測到人的面部。但是,我只能檢測到臉部,但它不會跟蹤臉部。Matlab GUI面部跟蹤功能
% --- 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);
我使用的圖像採集工具箱,並訪問了幾個網站,但我似乎無法解決問題。
任何幫助,非常感謝!
您好我已經試過這些例子,但我的計劃似乎並沒有工作 – Helen
@Helen,這些例子正是你所需要的。如果你確切地瞭解他們的工作方式,你應該可以根據你的項目調整他們的代碼。另請看看這個例子:http://www.mathworks.com/matlabcentral/fileexchange/47105-detect-and-track-multiplefaces – Dima