Tuesday, August 26, 2014

finding eigen values of a covariance matrix using Eigen library

Eigen::Vector4f xyz_centroid;
            
Eigen::Matrix3f covariance_matrix;
            
compute3DCentroid (voxel_cloud, pointIdxRadiusSearch, xyz_centroid);
            
pcl17::computeCovarianceMatrix (voxel_cloud, pointIdxRadiusSearch, xyz_centroid, covariance_matrix);
                
                
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eigen_solver(covariance_matrix);
                
//std::cout << "From Eigen Solver :  \n " << eigen_solver.eigenvalues() <<  std::endl;
                
Eigen::Vector3f temp1;

                
temp1 = eigen_solver.eigenvalues();

QT is by far the best IDE for C/C++

QT (pronounced as 'cute') is amazingly cute IDE for C/C++ :)

Wednesday, August 13, 2014

astyle is amazing

If you want your program to be indented automatically in a systematic/coherent way

Then here you go :

check this out
http://astyle.sourceforge.net/

Convert Point Cloud to Range Image to OpenCV Mat


source :
http://www.pcl-users.org/Convert-point-cloud-to-range-image-td4035137.html

Good tutorial

http://pointclouds.org/documentation/tutorials/project_inliers.php

Question:

HI,everyone, I'm trying to convert a 3d point cloud to a opencv mat. So here is my plan: 

1.convert the point cloud to a range image 

2.convert the range image to mat image 
Yet, I'm facing some problems, when I generate the range image by the example code with a terrain point cloud, it only gives me a very small window and nothing show up (other pcd file works). Is it because the pcd file too large? 

And is there any other way to convert the point cloud to opencv mat. Now I'm only caring about x,y data. So it's like a projection of point cloud and convert to a mat image. 


Thanks so much for your help~




Solution


If that is what you need it is exactly what you can do with the project 
inliers filter. 
http://docs.pointclouds.org/trunk/classpcl_1_1_project_inliers.html

just project the point cloud on the xy-Plane there is a tutorial for that: 
http://pointclouds.org/documentation/tutorials/project_inliers.php

after that you can the bounds of the plane by using pcl::getMinMax3D. 
Now you can define a top left and a bottom right corner (defining a rect) and 
compute a scale factor to match your image size. Say you want a 1000x1000px 
Image use 1000 / rect.width for x scale factor and 1000 / rect.height as y 
scale factor after that you can iterate over all points and set the 
corresponding pixels in the mat. cv::Mat::at(pt.x*scaleX, pt.y * scaleY) = 
pt.z After that you might have to to some interpolation to fill in the missing 
pixels and you have your opencv image.