IDS peak ICV v1.0.0
Loading...
Searching...
No Matches
peak_icv_point_cloud_xyzi.hpp
Go to the documentation of this file.
1
11#pragma once
12
21#include <peak_icv_c/types/peak_icv_point_cloud.h>
22#include <algorithm>
23#include <memory>
24#include <vector>
25
26namespace peak
27{
28namespace icv
29{
30
31namespace experimental
32{
33
42class PointCloudXYZI : public detail::PointCloud<PointCloudXYZI, PointXYZI>
43{
44
45public:
58 PointCloudXYZI(const XYZImage& xyzImage, const Image& intensityImage);
59
72 PointCloudXYZI(const peak::icv::experimental::UndistortedImage& undistortedDepthMap, const Image& intensityImage);
73
89 explicit PointCloudXYZI(const std::string& filePath, peak::common::PixelFormat pixelFormatName);
90
96 explicit PointCloudXYZI(const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName);
97
98protected:
99 PointCloudXYZI() = default;
100
101private:
102 friend peak::common::detail::BackendAccessor<PointCloudXYZI>;
103#ifndef DOXYGEN_SHOULD_SKIP_THIS // skip this as doxygen cannot handle friended base
105#endif /* DOXYGEN_SHOULD_SKIP_THIS */
106
107 static peak_icv_point_cloud_handle CreatePointCloudHandle(const XYZImage& xyzImage, const Image& intensityImage);
108 static peak_icv_point_type PointTypeFromPixelFormat(peak::common::PixelFormat pixelFormatName);
109 static peak_icv_point_cloud_handle LoadFromFile(const std::string& filePath, peak::common::PixelFormat pixelFormatName);
110 static peak_icv_point_cloud_handle CreateFromPoints(
111 const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName);
112};
113
114inline PointCloudXYZI::PointCloudXYZI(const XYZImage& xyzImage, const Image& intensityImage)
115 : PointCloud<PointCloudXYZI, PointXYZI>{ CreatePointCloudHandle(xyzImage, intensityImage) }
116{}
117
118inline PointCloudXYZI::PointCloudXYZI(const peak::icv::experimental::UndistortedImage& undistortedDepthMap, const Image& intensityImage)
119 : PointCloudXYZI(XYZImage(undistortedDepthMap), intensityImage)
120{}
121
122inline PointCloudXYZI::PointCloudXYZI(const std::string& filePath, peak::common::PixelFormat pixelFormatName)
123 : PointCloud<PointCloudXYZI, PointXYZI>{ LoadFromFile(filePath, pixelFormatName) }
124{}
125
126inline PointCloudXYZI::PointCloudXYZI(const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName)
127 : PointCloud<PointCloudXYZI, PointXYZI>{ CreateFromPoints(points, pixelFormatName) }
128{}
129
130inline peak_icv_point_cloud_handle PointCloudXYZI::CreatePointCloudHandle(const XYZImage& xyzImage, const Image& intensityImage)
131{
132 auto* const xyzImageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(xyzImage);
133 auto* const intensityImageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(intensityImage);
134
135 peak_icv_point_cloud_handle handle{};
137 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromXYZImageAndIntensityImage(
138 &handle, xyzImageHandle, intensityImageHandle);
139 });
140 return handle;
141}
142
143inline peak_icv_point_type PointCloudXYZI::PointTypeFromPixelFormat(peak::common::PixelFormat pixelFormatName)
144{
145 switch (pixelFormatName)
146 {
148 return PEAK_ICV_POINT_TYPE_XYZ_I8;
150 return PEAK_ICV_POINT_TYPE_XYZ_I10;
152 return PEAK_ICV_POINT_TYPE_XYZ_I12;
153 default:
154 throw peak::icv::NotSupportedException("The given pixel format is not supported!");
155 }
156}
157
158inline peak_icv_point_cloud_handle PointCloudXYZI::LoadFromFile(
159 const std::string& filePath, peak::common::PixelFormat pixelFormatName)
160{
161 peak_icv_point_cloud_handle handle{};
162
163
165 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromFile(
166 &handle, PointTypeFromPixelFormat(pixelFormatName), filePath.c_str());
167 });
168 return handle;
169}
170
171inline peak_icv_point_cloud_handle PointCloudXYZI::CreateFromPoints(
172 const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName)
173{
174 std::vector<peak_icv_point_xyzi> pointsC{};
175 pointsC.reserve(points.size());
176
177 std::transform(points.begin(), points.end(), std::back_inserter(pointsC), [](const PointXYZI& point) -> peak_icv_point_xyzi {
178 return { point.GetX(), point.GetY(), point.GetZ(), point.GetIntensity() };
179 });
180
181 peak_icv_point_cloud_handle pointCloudHandle{};
183 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromPoints(
184 &pointCloudHandle, pointsC.data(), pointsC.size(), PointTypeFromPixelFormat(pixelFormatName));
185 });
186 return pointCloudHandle;
187}
188} /* namespace experimental */
189
190
191} /* namespace icv */
192} /* namespace peak */
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
Thrown when a requested operation is not implemented or supported.
A point cloud consists of points with x, y, z coordinates and intensity meta data.
A point consists of x, y, z coordinates and intensity meta data.
Transforms an undistorted depth map with radial coordinates to a three-channel image with cartesian c...
PixelFormat
Enum listing all supported pixel formats and their internal IDs.
@ Mono12
Mono 12-Bit pixel format.
@ Mono10
Mono 10-Bit pixel format.
@ Mono8
Mono 8-Bit pixel format.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)