63 libfreenect2::Frame& registered,
64 typename pcl::PointCloud<PointT>::Ptr cloud)
66 const std::size_t w = undistorted.width;
67 const std::size_t h = undistorted.height;
69 cv::Mat tmp_itD0(undistorted.height, undistorted.width, CV_32FC1, undistorted.data);
70 cv::Mat tmp_itRGB0(registered.height, registered.width, CV_8UC4, registered.data);
75 cv::flip(tmp_itD0, tmp_itD0, 1);
76 cv::flip(tmp_itRGB0, tmp_itRGB0, 1);
79 const float* itD0 = (
float*)tmp_itD0.ptr();
80 const char* itRGB0 = (
char*)tmp_itRGB0.ptr();
82 PointT* itP = &cloud->points[0];
85 for (std::size_t y = 0; y < h; ++y)
88 const unsigned int offset = y * w;
89 const float* itD = itD0 + offset;
90 const char* itRGB = itRGB0 + offset * 4;
91 const float dy = rowmap(y);
92 bool color = pcl::traits::has_color<PointT>::value;
95 for (std::size_t
x = 0;
x < w; ++
x, ++itP, ++itD, itRGB += 4)
97 const float depth_value = *itD / 1000.0;
100 if (!std::isnan(depth_value) && (std::abs(depth_value) >= 0.0001))
103 const float rx = colmap(
x) * depth_value;
104 const float ry = dy * depth_value;
105 itP->z = depth_value;
125 cloud->is_dense = is_dense;