How can I deal or track only one face while I have detected all the faces in front of camera?

조회 수: 3 (최근 30일)
I have face recognition code which recognizes the face and show its name when I will generate the database for that, it is working well when only one face is in front of camera but I am using "FaceDetect = vision.CascadeObjectDetector;" for face detection which will detect all the faces in front of camera and I am getting bounding box around all the faces. Is there any way to track face of my choice among the detected all faces? Or can I code each bounding box face separately? Please give me some guideline. Thanks

채택된 답변

Aurele Turnes
Aurele Turnes 2014년 8월 5일
Once you have created your vision.CascadeObjectDetector object, you can apply it to your image I to detect the faces on the image as follows:
bboxes = step(faceDetect, I);
The returned matrix bboxes is M-by-4, where M is the number of faces detected and the 4 elements describe the bounding box around each face, as explained in the following documentation page:
To access the ith face, you can simply extract the corresponding pixels from the original image:
i = 1;
indexi = bboxes(i,:);
facei = I(indexi(2):indexi(2)+indexi(4),indexi(1):indexi(1)+indexi(3),:);
figure;
imagesc(facei)
You can then pass facei to your face recognition algorithm to detect which person this face corresponds to and track who is on the picture.
  댓글 수: 3
talal
talal 2014년 8월 13일
편집: Image Analyst 2014년 8월 15일
Dear Turnes,
First of all thanks for your answer. I am following your guidelines but I am facing some problems can you please help me.
index1=bbox(1,:);
face1=temp(index1(2):index1(2)+index1(4),index1(1):index1(1)+index1(3),:);
G=rgb2gray(face1);
R=imresize(G,[100,100]);
% imagesc(face1)
name1=recognize(R); .....my face recognition function
and I am getting error
Error using rgb2gray>parse_inputs (line 81)
MAP must be a m x 3 array.
Error in rgb2gray (line 35)
X = parse_inputs(varargin{:});
Error in get_face (line 11)
img=rgb2gray(img);
Thanks in advance
Aurele Turnes
Aurele Turnes 2014년 8월 15일
It seems like you are getting an error when you use the rgb2gray function because your frame face1 is only a 2D-matrix. The function rgb2gray expects its input to be in color, and thus to be a 3D-matrix. Can you check if your face1 frame is a 3D-matrix?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 8월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by