IDS peak ICV v1.2.0
Loading...
Searching...
No Matches
peak_icv_point_cloud_xyzi.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <peak_common_c/detail/peak_common_defines.h>
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
40class PointCloudXYZI : public detail::PointCloud<PointCloudXYZI, PointXYZI>
41{
42public:
56 PointCloudXYZI(const XYZImage& xyzImage, const Image& intensityImage);
57
80 PointCloudXYZI(const peak::icv::UndistortedImage& undistortedDepthMap, const Image& intensityImage);
81
100 explicit PointCloudXYZI(const std::string& filePath, peak::common::PixelFormat pixelFormatName);
101
112 explicit PointCloudXYZI(const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName);
113
114protected:
115 PointCloudXYZI() = default;
116
117private:
118 friend peak::common::detail::BackendAccessor<PointCloudXYZI>;
119#ifndef DOXYGEN_SHOULD_SKIP_THIS // skip this as doxygen cannot handle friended base
121#endif /* DOXYGEN_SHOULD_SKIP_THIS */
122
123 static peak_icv_point_cloud_handle CreatePointCloudHandle(const XYZImage& xyzImage, const Image& intensityImage);
124 static peak_icv_point_type PointTypeFromPixelFormat(peak::common::PixelFormat pixelFormatName);
125 static peak_icv_point_cloud_handle LoadFromFile(const std::string& filePath, peak::common::PixelFormat pixelFormatName);
126 static peak_icv_point_cloud_handle CreateFromPoints(
127 const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName);
128};
129
130inline PointCloudXYZI::PointCloudXYZI(const XYZImage& xyzImage, const Image& intensityImage)
131 : PointCloud<PointCloudXYZI, PointXYZI>{ CreatePointCloudHandle(xyzImage, intensityImage) }
132{}
133
134inline PointCloudXYZI::PointCloudXYZI(const peak::icv::UndistortedImage& undistortedDepthMap, const Image& intensityImage)
135 : PointCloudXYZI(XYZImage(undistortedDepthMap), intensityImage)
136{}
137
138inline PointCloudXYZI::PointCloudXYZI(const std::string& filePath, peak::common::PixelFormat pixelFormatName)
139 : PointCloud<PointCloudXYZI, PointXYZI>{ LoadFromFile(filePath, pixelFormatName) }
140{}
141
142inline PointCloudXYZI::PointCloudXYZI(const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName)
143 : PointCloud<PointCloudXYZI, PointXYZI>{ CreateFromPoints(points, pixelFormatName) }
144{}
145
146inline peak_icv_point_cloud_handle PointCloudXYZI::CreatePointCloudHandle(const XYZImage& xyzImage, const Image& intensityImage)
147{
148 auto* const xyzImageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(xyzImage);
149 auto* const intensityImageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(intensityImage);
150
151 peak_icv_point_cloud_handle handle{};
153 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromXYZImageAndIntensityImage(
154 &handle, xyzImageHandle, intensityImageHandle);
155 });
156 return handle;
157}
158
159inline peak_icv_point_type PointCloudXYZI::PointTypeFromPixelFormat(peak::common::PixelFormat pixelFormatName)
160{
161 switch (pixelFormatName)
162 {
164 return PEAK_ICV_POINT_TYPE_XYZ_I8;
166 return PEAK_ICV_POINT_TYPE_XYZ_I10;
168 return PEAK_ICV_POINT_TYPE_XYZ_I12;
169 default:
170 throw peak::icv::NotSupportedException("The given pixel format is not supported!");
171 }
172}
173
174inline peak_icv_point_cloud_handle PointCloudXYZI::LoadFromFile(
175 const std::string& filePath, peak::common::PixelFormat pixelFormatName)
176{
177 peak_icv_point_cloud_handle handle{};
178
179
181 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromFile(
182 &handle, PointTypeFromPixelFormat(pixelFormatName), filePath.c_str());
183 });
184 return handle;
185}
186
187inline peak_icv_point_cloud_handle PointCloudXYZI::CreateFromPoints(
188 const std::vector<PointXYZI>& points, peak::common::PixelFormat pixelFormatName)
189{
190 std::vector<peak_icv_point_xyzi> pointsC{};
191 pointsC.reserve(points.size());
192
193 std::transform(points.begin(), points.end(), std::back_inserter(pointsC), [](const PointXYZI& point) -> peak_icv_point_xyzi {
194 return { point.GetX(), point.GetY(), point.GetZ(), point.GetIntensity() };
195 });
196
197 peak_icv_point_cloud_handle pointCloudHandle{};
199 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromPoints(
200 &pointCloudHandle, pointsC.data(), pointsC.size(), PointTypeFromPixelFormat(pixelFormatName));
201 });
202 return pointCloudHandle;
203}
204
205} /* namespace icv */
206} /* 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.
Represents a point cloud consisting of points with x, y, z coordinates and an intensity value.
A point consists of x, y, z coordinates and intensity meta data.
Represents an image that has undergone undistortion.
Represents a three-channel image with Cartesian coordinates derived from an undistorted depth map.
Represents a generic point cloud interface for spatial data types.
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)