patrikhuber / superviseddescent

C++11 implementation of the supervised descent optimisation method
http://patrikhuber.github.io/superviseddescent/
Apache License 2.0
402 stars 188 forks source link

How to calculate the mean-face ? #1

Closed yxswjtu closed 9 years ago

yxswjtu commented 9 years ago

Hi patrikhuber,could you please release the code of calculating the "mean_ibug_lfpw_68.txt"?The result is exciting! I'm just a beginner in this area.

patrikhuber commented 9 years ago

Hi,

The mean face can be calculated in a few different ways - for example, one can align the training landmark coordinates using Procrustes (center them, scale, rotate...). But for this case, it's actually sufficient to just calculate the mean of the landmarks of a few hundred images, and you'll have a pretty good mean face.

If you look at examples/landmark_detection.cpp, you can just use cv::mean to calculate the mean of trainingLandmarks. As mentioned above, make sure you use enough images (i.e. more than the 5 in the data/ folder).

yxswjtu commented 9 years ago

Thank you for your answer!I used cv::mean to calculate the mean of landmarks,but the result is not so satisfied!I found the data in the mean_ibug_lfpw_68.txt is already normalized,could you please describe the detailed steps in your code?

yxswjtu commented 9 years ago

Hi, Patrik Huber,I solved my problems using Procrustes analysis.Thank you for your suggestions!

发自我的 iPad

在 2015年2月7日,05:26,Patrik Huber notifications@github.com 写道:

Hi,

The mean face can be calculated in a few different ways - for example, one can align the training landmark coordinates using Procrustes (center them, scale, rotate...). But for this case, it's actually sufficient to just calculate the mean of the landmarks of a few hundred images, and you'll have a pretty good mean face.

If you look at https://github.com/patrikhuber/superviseddescent/blob/master/examples/landmark_detection.cpp, you can just use cv::mean to calculate the mean of trainingLandmarks. As mentioned above, make sure you use enough images (i.e. more than the 5 in the data/ folder).

— Reply to this email directly or view it on GitHub.

patrikhuber commented 9 years ago

Hi,

I'm surprised your result was not satisfying - did you use enough (a few hundred) images, as I suggested? The normalisation I used in mean_ibug_lfpw_68.txt was just a simple scaling into a [-1, +1] x [-1, +1] box - and I determined the scale factor by using the face box from a face detector and then calculating the optimal scale factor at training time (imagine different face detectors output different face box sizes - one might be trained on only a narrow view of the face, another one might have a box around the whole head).

I will put the code of our full landmark detection online soon, so all these steps will be retraceable.

I'm glad you could solve your issue!

songminglong commented 9 years ago

Hi, I just run your program with data in the project(5 images and its pts file), then I put these in command line:./landmark_detection -d path-to-traindataset -m path-to-meanfile -f path-to-harrcascade...but I have waited for two hours , and no results output! I want to know how many times the train-step needed? Thanks for your reply!

patrikhuber commented 9 years ago

Hi Xiao-Hu, Sorry for the late reply, I was actually working on an update regarding this! I've just updated the library, it'll run much faster now. If you run ./landmark_detection ... again, it should finish in a few minutes now.

If you additionally compile with -fopenmp (/openmp on VS), it will be even faster and finish in a few seconds.

Let me know if you have any further problems.

PS: Next time, open a new issue, instead of replying in a closed issue - it will get done much faster :-)