codeniko / shape_predictor_81_face_landmarks

Custom shape predictor model trained to find 81 facial feature landmarks given any image
BSD 3-Clause "New" or "Revised" License
465 stars 126 forks source link

13 sfm indices #6

Closed huimxu closed 5 years ago

huimxu commented 5 years ago

hi,thank u for sharing your result~ i want to find some feature points in my own project as you did, how can i get the indices of the 13 sfm points?

codeniko commented 5 years ago

Hi, thanks for the support!

It's been a while but you can use https://github.com/patrikhuber/eos project (which has had a lot of updates since I've last used it as seen in my fork). You use an image and I believe provide the 68 landmarks to generate the surrey face model (check out ibug for a huge set of images and respective 68 landmark mappings). If you look at the SFM, it's actually composed of triangles which make up the mesh. Take the coordinates of the 3 corners of each triangle and you'll get a huge amount of points like this: https://github.com/codeniko/shape_predictor_81_face_landmarks/blob/master/full_mesh_example.png

Those points in the surrey face model will always map to the same spot in the model no matter what image it is. Make note of the indices that interest you and modify the eos project as follows:

As you iterate through your image set, load the 68 coordinates for each image, create the SFM, then extract coordinates of whatever SFM points that interested you earlier, modify the 68 point mapping file for that image to include your new landmark points. You'll result with a set of images with 68 + N points where N is the additional points you were interested in. Then using this data set and points, train your model using dlib trainer.

You can use my fork of eos as a reference for what I changed in the project to do what I described above https://github.com/codeniko/eos/commits/81-points

huimxu commented 5 years ago

thank u very much ~