patrikhuber / eos

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

Runtime of the current version #113

Closed Thanh-Binh closed 7 years ago

Thanh-Binh commented 7 years ago

I understood Patrik that the current version speed-ups 10x. Last Monday, I downloaded the current version and tested in my Ubuntu 16.04LTS. I modified the fit-model.cpp like std::chrono::system_clock::time_point t0 = std::chrono::system_clock::now(); std::tie(mesh, rendering_params) = fitting::fit_shape_and_pose(morphable_model, blendshapes, landmarks, landmark_mapper, image.cols, image.rows, edge_topology, ibug_contour, model_contour, 50, boost::none, 30.0f); std::chrono::system_clock::time_point t = std::chrono::system_clock::now(); std::cout << "runtime: "<< std::chrono::duration_cast(t - t0).count() << std::endl;

The runtime is about 870ms. I think, it is to slow. Did I do somethings wrong?

patrikhuber commented 7 years ago

If you're going for a real-time application, you shouldn't be running 50 iterations with all shape coefficients. Set num_iterations to 5 or so and num_shape_coefficients_to_fit to around 8 or so. Also make sure to set CMAKE_BUILD_TYPE=Release (you've probably done that).

Thanh-Binh commented 7 years ago

@patrikhuberafter changing num_iterations = 5 and num_shape_coefficients_to_fit=8, the rumtime is about 190ms. but it is really slower too

patrikhuber commented 7 years ago

It looks like the contour fitting is now the bottleneck - the pose and shape fitting require less than 1ms, but the ray-casting in the contour fitting takes around 50ms or so per iteration. I'm sure one can optimise this a lot.

If you use the 845 vertices model, this time goes down to around 3ms per iteration, as there are far fewer potential contour vertices to compute in that step. So the total runtime for 5 iterations should be below 25ms, if not less.

Thanh-Binh commented 7 years ago

I want to look at the source code. In fit-model-ceres, I have the following error: Error: The MorphableModel used does not contain a colour (albedo) model. ImageCost requires a model that contains a colour PCA model. You may want to use the full Surrey Face Model or remove this section. I really do not understand, how to avoid it. Could you pls help me? Binh

patrikhuber commented 7 years ago

I'm not sure what part you don't understand - the error pretty much explains what's going on and some options on what you can do. You can also have a look at the comments in the source code as well as above main(). If you have a more specific question, I might be able to help. Also if you are not familiar with what colour PCA model means, I recommend you read a paper with background about 3DMM's.

I am closing this since it is no longer about runtime, the runtime should be fine.