# include <pcl/io/ply_io.h> # include <iostream>
# include <pcl/io/pcd_io.h>
# include <pcl/visualization/pcl_visualizer.h>
# include <pcl/common/transforms.h> int main ( )
{ pcl:: PointCloud< pcl:: PointXYZ> :: Ptr pPointCloudIn ( new pcl:: PointCloud < pcl:: PointXYZ> ( ) ) ; pcl:: io:: loadPLYFile < pcl:: PointXYZ> ( "bunny.ply" , * pPointCloudIn) ; pcl:: visualization:: PCLVisualizer viewer; viewer. setCameraFieldOfView ( 0.785398 ) ; viewer. setBackgroundColor ( 0.5 , 0.5 , 0.5 ) ; viewer. setCameraPosition ( 0 , 0 , 3 , 0 , 0 , - 1 , 0 , 1 , 0 ) ; Eigen:: Matrix4f transform_1 = Eigen:: Matrix4f :: Identity ( ) ; float theta = M_PI / 4 ; transform_1 ( 0 , 0 ) = cos ( theta) ; transform_1 ( 0 , 1 ) = - sin ( theta) ; transform_1 ( 1 , 0 ) = sin ( theta) ; transform_1 ( 1 , 1 ) = cos ( theta) ; transform_1 ( 0 , 3 ) = 2.5 ; printf ( "Method #1: using a Matrix4f\n" ) ; std:: cout << transform_1 << std:: endl; Eigen:: Affine3f transform_2 = Eigen:: Affine3f :: Identity ( ) ; transform_2. translation ( ) << 2.5 , 0.0 , 0.0 ; transform_2. rotate ( Eigen :: AngleAxisf ( theta, Eigen:: Vector3f :: UnitZ ( ) ) ) ; printf ( "\nMethod #2: using an Affine3f\n" ) ; std:: cout << transform_2. matrix ( ) << std:: endl; pcl:: PointCloud< pcl:: PointXYZ> :: Ptr pPointCloudOut ( new pcl:: PointCloud < pcl:: PointXYZ> ( ) ) ; pcl:: transformPointCloud ( * pPointCloudIn, * pPointCloudOut, transform_1) ; pcl:: visualization:: PointCloudColorHandlerCustom< pcl:: PointXYZ> inColorHandler ( pPointCloudIn, 255 , 255 , 255 ) ; pcl:: visualization:: PointCloudColorHandlerCustom< pcl:: PointXYZ> outColorHandler ( pPointCloudOut, 230 , 20 , 20 ) ; viewer. addPointCloud ( pPointCloudIn, inColorHandler, "In" ) ; viewer. addPointCloud ( pPointCloudOut, outColorHandler, "Out" ) ; viewer. addCoordinateSystem ( 1.0 , "cloud" , 0 ) ; while ( ! viewer. wasStopped ( ) ) { viewer. spinOnce ( ) ; } std:: system ( "pause" ) ; return 0 ;
}