Advertisement
lamiastella

depth_to_pcl

Jun 12th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. pointcloud.width = width;
  2. pointcloud.height = height;
  3. pointcloud.points.resize (pointcloud.height * pointcloud.width);
  4.  
  5. int* depth_data = new int[pointcloud.height * pointcloud.width];
  6. //copy the depth values of every pixel in here
  7.  
  8. register float constant = 1.0f / 525;
  9. register int centerX = (pointcloud.width >> 1);
  10. int centerY = (pointcloud.height >> 1);
  11. register int depth_idx = 0;
  12. for (int v = -centerY; v < centerY; ++v)
  13. {
  14.         for (register int u = -centerX; u < centerX; ++u, ++depth_idx)
  15.         {
  16.                 pcl::PointXYZ& pt = pointcloud.points[depth_idx];
  17.                 pt.z = depth_data[depth_idx] * 0.001f;
  18.                 pt.x = static_cast<float> (u) * pt.z * constant;
  19.                 pt.y = static_cast<float> (v) * pt.z * constant;
  20.         }
  21. }
  22. pointcloud.sensor_origin_.setZero ();
  23. pointcloud.sensor_orientation_.w () = 0.0f;
  24. pointcloud.sensor_orientation_.x () = 1.0f;
  25. pointcloud.sensor_orientation_.y () = 0.0f;
  26. pointcloud.sensor_orientation_.z () = 0.0f;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement