Showing posts with label PCL. Show all posts
Showing posts with label PCL. Show all posts

Friday, October 24, 2014

Linking Error: undefined reference to symbol 'vtkCellArray::New()' when using pclVisualizer

While compiling the Correspondence_grouping code from pcl (http://www.pointclouds.org/documentation/tutorials/correspondence_grouping.php ) in my ROS Hydro workspace, I got following linking error:

Linking error:
 Linking CXX executable /home/swagatika/catkin_ws/devel/lib/my_pcl_tutorial/correspondence_grouping
/usr/bin/ld: CMakeFiles/correspondence_grouping.dir/src/correspondence_grouping.cpp.o: undefined reference to symbol 'vtkCellArray::New()'
/usr/bin/ld: note: 'vtkCellArray::New()' is defined in DSO /usr/lib/libvtkFiltering.so.5.8 so try adding it to the linker command line
/usr/lib/libvtkFiltering.so.5.8: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [/home/swagatika/catkin_ws/devel/lib/my_pcl_tutorial/correspondence_grouping] Error 1
make[1]: *** [my_pcl_tutorial/CMakeFiles/correspondence_grouping.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

Solution:

In  ~/catkin_was/src/my_pcl_tutorial/CMakeLists.txt :

add_executable(correspondence_grouping src/correspondence_grouping.cpp)
target_link_libraries(correspondence_grouping ${catkin_LIBRARIES} ${PCL_LIBRARIES} libvtkCommon.so libvtkFiltering.so )


Ref:

http://www.pointclouds.org/documentation/tutorials/correspondence_grouping.php
http://answers.ros.org/question/37096/error-when-using-pclvisualizer/

Tuesday, October 7, 2014

Quick PCL commands to capture data using Kinect

$ pcl_openni_viewer
 press 'r' to visualize the point cloud. Pointcloud appears inverted manner. have to use mouse to see in correct orientation.

you can see 2 windows (PCL OpenNI cloud, PCL OpenNI Image)

$ pcl_openni_save_image  (saves depth and RGB image in .tiff format... You have to stop it if you want to save only 1 frame.)


View the depth image in octave:

$octave
octave:1> imshow('1_1_depth.tiff' , [])

$ pcl_openni_grabber_example
Warning: USB events thread - failed to set priority. This might cause loss of data...
<Esc>, 'q', 'Q': quit the program
' ': pause
's': save


$ pcl_viewer pcd_file.pcd
(press r to view, 5 to see color)

Friday, September 26, 2014

PCL: pointcloud transformation




// transform the model by the transformation value
  Eigen::Matrix4f txform;
 

 //get the txformation matrix (discussed below)

 pcl::transformPointCloud (*cloud_3dmodel, *txformed_model, txform );


ICP can be used to estimate the transform :

Eigen::Matrix4f txform;

 pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB> icp;
 icp.setInputCloud(cloud_3dmodel);
 icp.setInputTarget(cloud_cluster);
 pcl::PointCloud<pcl::PointXYZRGB> Final;
 icp.align(Final);
 std::cout << "ICP has converged:" << icp.hasConverged() << " score: " <<    icp.getFitnessScore() << std::endl;

txform = icp.getFinalTransformation();

Refer:
http://stc0.wordpress.com/2013/03/22/equivalent-ways-to-register-two-point-clouds-with-pcl/
http://pointclouds.org/documentation/tutorials/iterative_closest_point.php 
http://robotica.unileon.es/mediawiki/index.php/PCL/OpenNI_tutorial_3:_Cloud_processing_%28advanced%29

Eigen: block access to matrices

  
 Eigen library: matrix block operation: 

 http://eigen.tuxfamily.org/dox-devel/group__TutorialBlockOperations.html


 //Code snippet to define a 4x4 transformation matrix:


  Eigen::Matrix4f txform;

  .........

  // Get Rotation Matrix and translation vector: T = [R | t]
  Eigen::Matrix3f rotation = txform.block<3,3>(0, 0);
  Eigen::Vector3f translation = txform.block<3,1>(0, 3);
 

  //Print he individual values
    printf ("\n");
    printf ("            | %6.3f %6.3f %6.3f | \n", rotation (0,0), rotation (0,1), rotation (0,2));
    printf ("        R = | %6.3f %6.3f %6.3f | \n", rotation (1,0), rotation (1,1), rotation (1,2));
    printf ("            | %6.3f %6.3f %6.3f | \n", rotation (2,0), rotation (2,1), rotation (2,2));
    printf ("\n");
    printf ("        t = < %0.3f, %0.3f, %0.3f >\n", translation (0), translation (1), translation (2));