Showing posts with label Eigen. Show all posts
Showing posts with label Eigen. Show all posts

Friday, June 12, 2009

Easy rotation with Eigen quaternions

Currently working on improving an alignment software for time-of-flight depth maps, I have to say I find the functions offered by Eigen quite useful.
Considering the two points clouds below (rendered with VTK), the first step to align them is to rotate them correctly.
















For this task, I use a simple RANSAC to find the largest plane in the point cloud. Then, having the plane normal vector nVec3, finding the rotation matrix mat that will align this plane with the Z-axis is 2 Eigen calls away :

Eigen::Vector3d nVecZ; nVecZ.UnitZ();
Eigen::Quaterniond qz; qz.setFromTwoVectors(nVec3, nVecZ);
Eigen::Matrix3d mat = qz.toRotationMatrix();

And here is the result for the dataset above:



That's 2 rotation DoF taken care of. Imposing the matched planes to have the same distance to origin takes care of one translation DoF. One rotation and 2 translations to go ;-)

Thursday, June 4, 2009

Mercurial on Mac - UTF-8 locale problems

The Eigen project recently switched to Mercurial. After installing the Macports version of mercurial, it wouldn't work apparently due to locale problems. The solution from this blog post worked for me :

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8


Thanks Lothar. It's really good when the first hit from a google search is spot on. Now I should get back to my own code and build problems.