IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
peak_icv_point_cloud_xyz.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <peak_common_c/detail/peak_common_defines.h>
23#include <peak_icv_c/types/peak_icv_point_cloud.h>
24#include <algorithm>
25#include <memory>
26#include <vector>
27
28namespace peak
29{
30namespace icv
31{
32
41class PointCloudXYZ : public detail::PointCloud<PointCloudXYZ, PointXYZ>
42{
43public:
53 explicit PointCloudXYZ(const XYZImage& image);
54
73 explicit PointCloudXYZ(const UndistortedImage& undistortedDepthMap);
74
91 explicit PointCloudXYZ(const std::string& filePath);
92
100 explicit PointCloudXYZ(const std::vector<PointXYZ>& points);
101
102protected:
103 PointCloudXYZ() = default;
104
105private:
106#ifndef DOXYGEN_SHOULD_SKIP_THIS // skip this as doxygen cannot handle friended base
108#endif /* DOXYGEN_SHOULD_SKIP_THIS */
109
110 friend peak::common::detail::BackendAccessor<PointCloudXYZ>;
111
112 static peak_icv_point_cloud_handle CreatePointCloudHandle(const XYZImage& image);
113 static peak_icv_point_cloud_handle LoadFromFile(const std::string& filePath);
114 static peak_icv_point_cloud_handle CreateFromPoints(const std::vector<PointXYZ>& points);
115};
116
117inline PointCloudXYZ::PointCloudXYZ(const XYZImage& image)
118 : PointCloud<PointCloudXYZ, PointXYZ>{ CreatePointCloudHandle(image) }
119{}
120
121inline PointCloudXYZ::PointCloudXYZ(const UndistortedImage& undistortedDepthMap)
122 : PointCloudXYZ{ XYZImage{ undistortedDepthMap } }
123{}
124
125inline PointCloudXYZ::PointCloudXYZ(const std::string& filePath)
126 : PointCloud<PointCloudXYZ, PointXYZ>{ LoadFromFile(filePath) }
127{}
128
129inline PointCloudXYZ::PointCloudXYZ(const std::vector<PointXYZ>& points)
130 : PointCloud<PointCloudXYZ, PointXYZ>{ CreateFromPoints(points) }
131{}
132
133inline peak_icv_point_cloud_handle PointCloudXYZ::CreatePointCloudHandle(const XYZImage& image)
134{
135 auto* const imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(image);
136
137 peak_icv_point_cloud_handle pointCloudHandle{};
139 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromXYZImage(&pointCloudHandle, imageHandle);
140 });
141 return pointCloudHandle;
142}
143
144inline peak_icv_point_cloud_handle PointCloudXYZ::LoadFromFile(const std::string& filePath)
145{
146 peak_icv_point_cloud_handle handle{};
148 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromFile(&handle, PEAK_ICV_POINT_TYPE_XYZ, filePath.c_str());
149 });
150 return handle;
151}
152
153inline peak_icv_point_cloud_handle PointCloudXYZ::CreateFromPoints(const std::vector<PointXYZ>& points)
154{
155 std::vector<peak_icv_point_xyz> pointsC(points.size());
156
157 std::transform(points.begin(), points.end(), pointsC.begin(), [](const PointXYZ& point) -> peak_icv_point_xyz {
158 return { point.GetX(), point.GetY(), point.GetZ(), {} };
159 });
160
161 peak_icv_point_cloud_handle pointCloudHandle{};
163 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromPoints(
164 &pointCloudHandle, pointsC.data(), pointsC.size(), PEAK_ICV_POINT_TYPE_XYZ);
165 });
166 return pointCloudHandle;
167}
168
169} /* namespace icv */
170} /* namespace peak */
Represents a point cloud consisting of points with x, y, and z coordinates.
A point consists of x, y and z coordinate.
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.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)