3 #include <pcl/point_types.h> 12 pcl::PointCloud<pcl::PointXYZ>::Ptr
pointCloudFromNxLib(NxLibItem
const& node, std::string
const& frame,
17 std::vector<float> data;
19 node.getBinaryDataInfo(&width, &height, 0, 0, 0, ×tamp);
20 node.getBinaryData(data, 0);
22 auto cloud = boost::make_shared<pcl::PointCloud<pcl::PointXYZ>>();
26 cloud->header.frame_id = frame;
29 cloud->height = height;
30 cloud->is_dense =
false;
31 cloud->points.resize(width * height);
32 for (
int i = 0; i < width * height; i++)
34 cloud->points[i].x = data[3 * i] / 1000.0f;
35 cloud->points[i].y = data[3 * i + 1] / 1000.0f;
36 cloud->points[i].z = data[3 * i + 2] / 1000.0f;
38 if (roi !=
nullptr && !roi->
contains(cloud->points[i].x, cloud->points[i].y, cloud->points[i].z))
40 cloud->points[i].x = std::numeric_limits<float>::quiet_NaN();
41 cloud->points[i].y = std::numeric_limits<float>::quiet_NaN();
42 cloud->points[i].z = std::numeric_limits<float>::quiet_NaN();
50 NxLibItem
const& normalNode,
51 std::string
const& frame,
56 std::vector<float> pointData;
57 std::vector<float> normalData;
59 pointMapNode.getBinaryDataInfo(&width, &height, 0, 0, 0, ×tamp);
60 pointMapNode.getBinaryData(pointData, 0);
61 normalNode.getBinaryData(normalData, 0);
63 auto cloud = boost::make_shared<pcl::PointCloud<pcl::PointNormal>>();
67 cloud->header.frame_id = frame;
70 cloud->height = height;
71 cloud->is_dense =
false;
72 cloud->points.resize(width * height);
73 for (
int i = 0; i < width * height; i++)
76 cloud->points[i].x = pointData[3 * i] / 1000.0f;
77 cloud->points[i].y = pointData[3 * i + 1] / 1000.0f;
78 cloud->points[i].z = pointData[3 * i + 2] / 1000.0f;
80 if (roi !=
nullptr && !roi->
contains(cloud->points[i].x, cloud->points[i].y, cloud->points[i].z))
82 cloud->points[i].x = std::numeric_limits<float>::quiet_NaN();
83 cloud->points[i].y = std::numeric_limits<float>::quiet_NaN();
84 cloud->points[i].z = std::numeric_limits<float>::quiet_NaN();
88 cloud->points[i].normal_x = normalData[3 * i];
89 cloud->points[i].normal_y = normalData[3 * i + 1];
90 cloud->points[i].normal_z = normalData[3 * i + 2];
96 NxLibItem
const& pointsNode,
102 std::vector<float> data;
103 std::vector<unsigned char> imageData;
105 pointsNode.getBinaryDataInfo(&width, &height, 0, 0, 0, 0);
106 pointsNode.getBinaryData(data, ×tamp);
107 imageNode.getBinaryData(imageData, 0);
109 auto cloud_colored = boost::make_shared<pcl::PointCloud<pcl::PointXYZRGB>>();
113 cloud_colored->header.frame_id = frame;
115 cloud_colored->width = width;
116 cloud_colored->height = height;
117 cloud_colored->is_dense =
false;
118 cloud_colored->points.resize(width * height);
120 for (
int i = 0; i < width * height; i++)
122 cloud_colored->points[i].x = data[3 * i] / 1000.0f;
123 cloud_colored->points[i].y = data[3 * i + 1] / 1000.0f;
124 cloud_colored->points[i].z = data[3 * i + 2] / 1000.0f;
126 cloud_colored->points[i].r = imageData[4 * i];
127 cloud_colored->points[i].g = imageData[4 * i + 1];
128 cloud_colored->points[i].b = imageData[4 * i + 2];
129 cloud_colored->points[i].a = imageData[4 * i + 3];
131 if (roi !=
nullptr &&
132 !roi->
contains(cloud_colored->points[i].x, cloud_colored->points[i].y, cloud_colored->points[i].z))
134 cloud_colored->points[i].x = std::numeric_limits<float>::quiet_NaN();
135 cloud_colored->points[i].y = std::numeric_limits<float>::quiet_NaN();
136 cloud_colored->points[i].z = std::numeric_limits<float>::quiet_NaN();
140 return cloud_colored;
pcl::PointCloud< pcl::PointXYZ >::Ptr pointCloudFromNxLib(NxLibItem const &node, std::string const &frame, PointCloudROI const *roi)
double const NXLIB_TIMESTAMP_OFFSET
pcl::PointCloud< pcl::PointXYZRGB >::Ptr pointCloudTexturedFromNxLib(NxLibItem const &imageNode, NxLibItem const &pointsNode, std::string const &frame, PointCloudROI const *roi)
pcl::PointCloud< pcl::PointNormal >::Ptr pointCloudWithNormalsFromNxLib(NxLibItem const &pointMapNode, NxLibItem const &normalNode, std::string const &frame, PointCloudROI const *roi)
bool contains(float x, float y, float z) const