Face Detection Isolating faces

2 次查看(过去 30 天)
Jonathan
Jonathan 2013-10-25
Hi guys, I have recently tried the viola jones cascedeobjectdetector to detect faces and it works great. The only thing that I am having trouble is to crop out the faces, isolate and save them individually. have used the icrop function but still stuck thinking of a method to isolate them.. Anyone have any idea?
  1 个评论
Jonathan
Jonathan 2013-10-25
At the moment I can only do one lame thing which is this. I=imread('1.jpg'); %I = rgb2gray(I); faceDetector = vision.CascadeObjectDetector(); bbox_face = step(faceDetector, I);
I_faces = insertObjectAnnotation(I, 'rectangle', bbox_face, 'Face'); figure, imshow(I_faces), title('Detected faces');
for i=1: length(bbox_face) Icrop= imcrop(I,bbox_face(i,:));
Y= Icrop; if i==1 imwrite(Y,'cropped.jpg'); elseif i==2 imwrite(Y,'cropped2.jpg' ); elseif i==3 imwrite(Y,'cropped3.jpg'); else imwrite(Y,'cropped4.jpg' );
end end
Do advice if theres a better way :D

请先登录,再进行评论。

回答(1 个)

Anandakumar Selvaraj
you can try this code to crop the face
faceBBox = step(faceDetector,videoFrame);
x = faceBBox(1); y = faceBBox(2); w = faceBBox(3); h = faceBBox(4);
bboxPolygon = [x, y, x+w, y, x+w, y+1.56*h, x, y+1.56*h];
face = imcrop(videoFrame,faceBBox);

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by