kylemcdonald / FaceTracker

Real time deformable face tracking in C++ with OpenCV 3.
MIT License
1k stars 360 forks source link

Get which points identify mouth and eyes. #13

Closed Neogene closed 10 years ago

Neogene commented 10 years ago

The face tracking works really flawlessly but how can we detect which are the points that compose the eyes and the mouth? They are the ones inside the face shape perimeter but there is a way to get them precisely to define three polygons to create a mask (i'm trying to use the face to create a mask to apply to a texture to avoid the texture cover the eyes and the mouth area). thanx in advance. The idea is to fill the face area without filling the eyes and mouth polygons to generate the mask to be applied to a texture centered to the nose of the human.

kylemcdonald commented 10 years ago

tracker.getImageFeature(ofxFaceTracker::LEFT_EYE); tracker.getImageFeature(ofxFaceTracker::RIGHT_EYE); tracker.getImageFeature(ofxFaceTracker::OUTER_MOUTH); tracker.getImageFeature(ofxFaceTracker::INNER_MOUTH);

these return polylines for the features you're interested in.

Neogene commented 10 years ago

Thank you, but this is for openframeworks not for the FaceTracker OpenCV plain (only c++) project.

kylemcdonald commented 10 years ago

sorry! i thought we were talking ofxFaceTracker :)

that said, ofxFaceTracker is a good reference for how to get this kind of data.

inner mouth: {48,60,61,62,54,63,64,65}
outer mouth: consecutive(48, 60)
left eye: consecutive(36, 42)
right eye: consecutive(42, 48)

and the place you're looking is:

const Mat& shape = tracker._shape;
int n = shape.rows / 2;
shape.db(i, 0), shape.db(i + n, 0)
Neogene commented 10 years ago

Thank you, for others users in need i'm listing here all the points intervals:

face: consecutive (0,16) left eyelash: consecutive(17,21) right eyelash: consecutive(22,26) nose: consecutive(27,30) (33 may be counted too) nostrils: consecutive(31,35) (may be splitted in 31&32 for left, 34&35 for right and 33 for center) left eye: consecutive(36, 42) right eye: consecutive(42, 48) inner mouth: {48,60,61,62,54,63,64,65} outer mouth: consecutive(48, 60)

kylemcdonald commented 10 years ago

next time i need to refactor ofxFaceTracker, i will try to move extra API features like this into FaceTracker directly.

Neogene commented 10 years ago

Yes, a nice addition would be to add/enable full face shape detection, including the forehead, i've seen this in other samples around the web, the only way for now i've found is to shift upward (ok i know it's really a crap way) the eyelash points to simulate the forehead area.

mosspassion commented 8 years ago

@Neogene How did you raise the eyelash points higher? I want a forehead mask too, and I'm trying to get ride of the eyes and mouth hole.