patrikhuber / eos

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

Where is focal length? #302

Closed KirtoXX closed 4 years ago

KirtoXX commented 4 years ago

Hi patrikhuber Amazing work! I am a new beginner of eos. Casue i want to generate depth img of a face,but it is hard to do it while i can not get focal length,i gase it is a const value in your code. where can i find it?

patrikhuber commented 4 years ago

Hi @KirtoXX,

Thanks for the nice words!

The shape-to-landmarks fitting of eos uses a scaled orthographic / affine projection model. I would suggest you read O. Aldrian & W. Smith, Inverse Rendering of Faces with a 3D Morphable Model, PAMI 2013 (from the Readme), to get a better overview about it. I would also suggest that you get more familiar with projection models (i.e. scaled orthographic, perspective) from a graphics text book. You can also have a look at fit-model-ceres to get some inspiration of how to use non-linear fitting to estimate focal length. Though it's a highly underconstrained problem, in particular if trying to estimate it from a single image.

Potentially you could get depth (z) values from the estimated mesh?

KirtoXX commented 4 years ago

Hi @patrikhuber , Thanks for ur answer. I have get familiar with scaled projection models with your tips.Now I know that why your choise projection models to slove P_affrine. Could your pls give me some tips about how to slove scale factor of projection models? Cause I want to ues scale factor to build mat P and R T. In paper,lmks and shape model are norm to sqrt(2) and sqrt(3) by mat T and mat U, could we use it to solve scale?

patrikhuber commented 4 years ago

@KirtoXX Actually eos estimates camera parameters with a scaled orthographic projection (SOP) model, and gives you R, T and s. See here: https://github.com/patrikhuber/eos/blob/master/include/eos/fitting/orthographic_camera_estimation_linear.hpp. You can look more closely at this algorithm, it's quite neat. All the references are given in the code comments for further reading.

KirtoXX commented 4 years ago

@patrikhuber I have read https://github.com/patrikhuber/eos/blob/master/include/eos/fitting/affine_camera_estimation.hpp for a long time,thanks a lot!

patrikhuber commented 4 years ago

Actually I think the file affine_camera_estimation.hpp could be / should be removed - I can see that it still uses OpenCV, which has been removed as a dependency from eos a long time ago. I don't think this code is used anywhere anymore. Thanks for pointing me to it. I've opened #303 to track this.

KirtoXX commented 4 years ago

Hi @patrikhuber I have saved full_projection_3x4 mat by render param which store view_model,ortho_projection,but when i dot it by mesh, I find that face not in image center,could u pls give me some tips?

patrikhuber commented 4 years ago

@KirtoXX Please search the other issues (including closed ones), there is some comments and code on how to use the parameters to project the mesh to an image in Python.