patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.89k stars 596 forks source link

Residual and Jacobian evaluation failed when run fit-model-ceres #268

Closed sheuchenko closed 4 years ago

sheuchenko commented 4 years ago

Hi,

Firstly, thanks for the amazing library!I have run the fit-model.cpp and successfully got the desired result.

As I want to estimate the perspective projection, so I try to run the fit-model-ceres.cpp. The code changes are only related to file path and landmarks reading, and the "use_perspective" is set as false. However, it failed and reported that -- E0711 10:51:07.129752 26124 trust_region_minimizer.cc:72] Terminating: Residual and Jacobian evaluation failed.

Anyone encounter this problem before? Would you please give some hints?

patrikhuber commented 4 years ago

Hi,

Thanks a lot for the nice words!

All the Ceres code in eos actually uses AutoDiff, so there shouldn't be any problems with residual or Jacobian evaluation. I'm thinking that either 1) you have a weird/broken build of Ceres, or, more likely, 2) you are feeding it some broken/incomplete data (perhaps no landmarks or two few landmarks or something else). I recommend you step through the code of your fit-model-ceres and I am pretty sure that you will find the mistake where it goes wrong.

sheuchenko commented 4 years ago

Thanks for Patrik's kindly reply. I notice that, in the fit-model-ceres source code, it needs load the "../share/sfm_3448.bin". But I do not have this model, so I rewrite it to load "../share/sfm_shape_3448.bin". I wonder if it will lead the result of "Residual and Jacobian evaluation failed"? The error happens while solving the fitting::LandmarkCost.

patrikhuber commented 4 years ago

Regarding the shape/colour model, the fit-model-ceres code has a note and actually tells you what it's about. See also #181.

But since your problem is in the LandmarkCost, I think you've got a different problem, along the lines of what I suggested above.

I could also recommend that you read some basic 3DMM papers to get a better idea what landmark/camera/colour fitting is about.

JMingKuo commented 4 years ago

I have encountered the same error with vcpkg in x86. It is most likely a problem due to incomplete ceres installation. Rebuild all dependencies from scratch in x64 just solve this problem in my side. (opencv, boost, etc)

patrikhuber commented 4 years ago

Thanks for reporting your experience @JMingKuo :-)

I am closing this as it's been open without any activity for a while, and as this is quite sure not an eos problem, but a problem with the user's installation/code.