3 #include <pcl/point_cloud.h>
4 #include <pcl/point_types.h>
6 #include <ArmarXCore/interface/core/SharedMemory.h>
11 #include <Image/ByteImage.h>
18 typedef pcl::PointXYZRGBL PointL;
28 armarx::MetaInfoSizeBasePtr imageMetaInfo,
30 pcl::PointCloud<pcl::PointXYZRGBL>::Ptr& result);
32 template <
typename Po
intCloudPtrT>
35 armarx::MetaInfoSizeBasePtr imageMetaInfo,
36 PointCloudPtrT& result)
40 result->width = images[0]->width;
41 result->height = images[0]->height;
42 result->header.stamp = imageMetaInfo->timeProvided;
43 result->points.resize(images[0]->width * images[0]->height);
44 result->is_dense =
true;
47 const size_t width =
static_cast<size_t>(images[0]->width);
48 const size_t height =
static_cast<size_t>(images[0]->height);
49 const float halfWidth = (width / 2.0);
50 const float halfHeight = (height / 2.0);
51 const auto& image0Data = images[0]->pixels;
52 const auto& image1Data = images[1]->pixels;
54 for (
size_t j = 0; j < height; j++)
56 for (
size_t i = 0; i < width; i++)
58 auto coord = j * width + i;
62 image1Data[3 * coord + 1],
63 image1Data[3 * coord + 2]);
65 PointT& p = result->points.at(coord);
66 auto index = 3 * (coord);
67 p.r = image0Data[
index + 0];
68 p.g = image0Data[
index + 1];
69 p.b = image0Data[
index + 2];
73 p.x = p.y = p.z = std::numeric_limits<float>::quiet_NaN();
77 p.z =
static_cast<float>(
value);
79 p.x = -1.0 * (i - halfWidth) / width * p.z * scaleX;
80 p.y = (halfHeight - j) / height * p.z * scaleY;