3 #include <pcl/point_types.h>
4 #include <pcl/point_cloud.h>
6 #include <ArmarXCore/interface/core/SharedMemory.h>
7 #include <Image/ByteImage.h>
15 typedef pcl::PointXYZRGBL PointL;
24 void convertDepthImageToPointCloud(CByteImage** images, armarx::MetaInfoSizeBasePtr imageMetaInfo,
size_t numImages, pcl::PointCloud<pcl::PointXYZRGBL>::Ptr& result);
26 template <
typename Po
intCloudPtrT>
31 result->width = images[0]->width;
32 result->height = images[0]->height;
33 result->header.stamp = imageMetaInfo->timeProvided;
34 result->points.resize(images[0]->width * images[0]->height);
35 result->is_dense =
true;
39 const size_t width =
static_cast<size_t>(images[0]->width);
40 const size_t height =
static_cast<size_t>(images[0]->height);
41 const float halfWidth = (width / 2.0);
42 const float halfHeight = (height / 2.0);
43 const auto& image0Data = images[0]->pixels;
44 const auto& image1Data = images[1]->pixels;
46 for (
size_t j = 0; j < height; j++)
48 for (
size_t i = 0; i < width; i++)
50 auto coord = j * width + i;
55 PointT& p = result->points.at(coord);
56 auto index = 3 * (coord);
57 p.r = image0Data[
index + 0];
58 p.g = image0Data[
index + 1];
59 p.b = image0Data[
index + 2];
63 p.x = p.y = p.z = std::numeric_limits<float>::quiet_NaN();
67 p.z =
static_cast<float>(
value);
69 p.x = -1.0 * (i - halfWidth) / width * p.z * scaleX;
70 p.y = (halfHeight - j) / height * p.z * scaleY;