IDS peak ICV v1.0.0
Loading...
Searching...
No Matches
peak_icv_point_cloud_xyz.hpp
Go to the documentation of this file.
1
11#pragma once
12
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
33namespace experimental
34{
35
44class PointCloudXYZ : public detail::PointCloud<PointCloudXYZ, PointXYZ>
45
46{
47
48public:
58 explicit PointCloudXYZ(const XYZImage& image);
59
70 explicit PointCloudXYZ(const UndistortedImage& undistortedDepthMap);
71
86 explicit PointCloudXYZ(const std::string& filePath);
87
93 explicit PointCloudXYZ(const std::vector<PointXYZ>& points);
94
95protected:
96 PointCloudXYZ() = default;
97
98private:
99#ifndef DOXYGEN_SHOULD_SKIP_THIS // skip this as doxygen cannot handle friended base
101#endif /* DOXYGEN_SHOULD_SKIP_THIS */
102
103 friend peak::common::detail::BackendAccessor<PointCloudXYZ>;
104
105 static peak_icv_point_cloud_handle CreatePointCloudHandle(const XYZImage& image);
106 static peak_icv_point_cloud_handle LoadFromFile(const std::string& filePath);
107 static peak_icv_point_cloud_handle CreateFromPoints(const std::vector<PointXYZ>& points);
108};
109
110inline PointCloudXYZ::PointCloudXYZ(const XYZImage& image)
111 : PointCloud<PointCloudXYZ, PointXYZ>{ CreatePointCloudHandle(image) }
112{}
113
114inline PointCloudXYZ::PointCloudXYZ(const UndistortedImage& undistortedDepthMap)
115 : PointCloudXYZ{ XYZImage{ undistortedDepthMap } }
116{}
117
118inline PointCloudXYZ::PointCloudXYZ(const std::string& filePath)
119 : PointCloud<PointCloudXYZ, PointXYZ>{ LoadFromFile(filePath) }
120{}
121
122inline PointCloudXYZ::PointCloudXYZ(const std::vector<PointXYZ>& points)
123 : PointCloud<PointCloudXYZ, PointXYZ>{ CreateFromPoints(points) }
124{}
125
126inline peak_icv_point_cloud_handle PointCloudXYZ::CreatePointCloudHandle(const XYZImage& image)
127{
128 auto* const imageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(image);
129
130 peak_icv_point_cloud_handle pointCloudHandle{};
132 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromXYZImage(&pointCloudHandle, imageHandle);
133 });
134 return pointCloudHandle;
135}
136
137inline peak_icv_point_cloud_handle PointCloudXYZ::LoadFromFile(const std::string& filePath)
138{
139 peak_icv_point_cloud_handle handle{};
141 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromFile(&handle, PEAK_ICV_POINT_TYPE_XYZ, filePath.c_str());
142 });
143 return handle;
144}
145
146inline peak_icv_point_cloud_handle PointCloudXYZ::CreateFromPoints(const std::vector<PointXYZ>& points)
147{
148 std::vector<peak_icv_point_xyz> pointsC(points.size());
149
150 std::transform(points.begin(), points.end(), pointsC.begin(), [](const PointXYZ& point) -> peak_icv_point_xyz {
151 return { point.GetX(), point.GetY(), point.GetZ(), {} };
152 });
153
154 peak_icv_point_cloud_handle pointCloudHandle{};
156 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_CreateFromPoints(
157 &pointCloudHandle, pointsC.data(), pointsC.size(), PEAK_ICV_POINT_TYPE_XYZ);
158 });
159 return pointCloudHandle;
160}
161} /* namespace experimental */
162
163} /* namespace icv */
164} /* namespace peak */
A point cloud consists of points with x, y and z coordinates.
A point consists of x, y and z coordinate.
Transforms an undistorted depth map with radial coordinates to a three-channel image with cartesian c...
void ExecuteAndMapReturnCodes(const CallableType &callableObject)