meshcgalaffinetransform

Align two topologically identical meshes


I have two meshes who represent two different heads, as in not geometrically identical, but have the same topology. Also, a subset of those points represents the same features on the human face, i.e the tip of the nose, chin, angle of mouth, and so on; they are used in the topology transfer algorithm from which the modified mesh comes from.

Now, while the topologies match, as in the two meshes have the same points numbers, and the points are connected in the same way, the object are not optimally oriented in space.

I'm looking for the name of the optimization step that would better align the two meshes, and whether this concept somehow already exists in CGAL.

The distance between the two meshes could be just the sum of the distances between the matching points, or something more subtle which could give more weight to the points close to the landmarks used in the earlier step. Any linear transformation is admissible, but the ones that make more sense in this context are translations, rotations and scaling.

Files are here is you're interested in having a look

enter image description here


Solution

  • I found a way to do it - not in CGAL, but in OpenCV

    Function is: estimateAffine3D

    estimateAffine3D() int cv::estimateAffine3D ( InputArray src, InputArray dst, OutputArray out, OutputArray inliers, double ransacThreshold = 3, double confidence = 0.99 )

    Computes an optimal affine transformation between two 3D point sets.

    It computes R and T, such that P' = RxP + T , and the distances between the matching points in each set is minimized. R rotation matrix, T translation matrix.