Face Detection Isolating faces

2 visualizzazioni (ultimi 30 giorni)
Jonathan
Jonathan il 25 Ott 2013
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 Commento
Jonathan
Jonathan il 25 Ott 2013
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

Accedi per commentare.

Risposte (1)

Anandakumar Selvaraj
Anandakumar Selvaraj il 27 Nov 2013
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);

Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by