Point cloud Turn Depth diagram display function:
void Depthvisual () {//Object for storing the point cloud.
PCL::P OINTCLOUD<PCL::P ointxyz>::P TR Cloud (New PCL::P OINTCLOUD<PCL::P ointxyz>);
Object for storing the normals.
PCL::P ointcloud<pcl::normal>::P tr normals (new PCL::P ointcloud<pcl::normal>);
Read a PCD file from disk.
if (PCL::IO::LOADPCDFILE<PCL::P ointxyz> ("VINCENT.PCD", *cloud)!= 0) {return;
} eigen::matrix4f T;
T << 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 500, 0, 0, 0, 1;
eigen::matrix4f T1;
T1 << 0,-1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1;
eigen::affine3f Traw (T*T1); Parameters needed by the planar range image object://Image size.
Both Kinect and xtion work at 640x480.
int Imagesizex = 1500;
int Imagesizey = 1500; Center of projection.
Here, we choose the middle of the image.
float CenterX = imagesizex/2.0f;
float centery = imagesizey/2.0f; Focal length.
The value seen here is has been taken from the original depth.It is safe to use the same value vertically and horizontally.
float focallengthx = 800.0f, focallengthy = focallengthx; Sensor pose.
Thankfully, the cloud includes the data.
eigen::affine3f sensorpose = traw;//eigen::affine3f (eigen::translation3f (0, 0, 0)); Noise level.
If greater than 0, values of neighboring points would be averaged.
This would set the search radius (e.g., 0.03 = 3cm).
float noiselevel = 0.0f; Minimum range.
If set, any point closer to the sensor than this'll be ignored.
float minimumrange = 0.0f;
Planar range Image object.
Pcl::rangeimageplanar Rangeimageplanar; Rangeimageplanar.createfrompointcloudwithfixedsize (*cloud, Imagesizex, Imagesizey, CenterX, CenterY, FocalLengthX,
Focallengthx, Sensorpose, Pcl::rangeimage::laser_frame, Noiselevel, Minimumrange);
Visualize the image.
Pcl::visualization::rangeimagevisualizer Viewer ("Planar range image");
Viewer.showrangeimage (Rangeimageplanar); while (!viewer.wasstopped ()) {
Viewer.spinonce ();
Sleep 100ms to go easy on the CPU.
Pcl_sleep (0.1); }
}