40 : base(CreateFromXYZImage(image, intensityImage))
70 : base(CreateFromUndistortedImage(undistortedDepthMap, intensityImage))
102 : base(LoadFromFile(filePath, pixelFormat))
120 : base(CreateFromPoints(points, pixelFormat))
145 DllHelper.ExecuteAndMapReturnCodes(() =>
146 CInterface.peak_icv_PointCloud_GetPoints_GetCount(_handle, out numPoints));
154 var pointsC =
new Backend.Types.peak_icv_point_xyzi[numPoints];
155 var size = Marshal.SizeOf<Backend.Types.peak_icv_point_xyzi>();
157 var handle = GCHandle.Alloc(pointsC, GCHandleType.Pinned);
161 IntPtr ptr = handle.AddrOfPinnedObject();
163 DllHelper.ExecuteAndMapReturnCodes(() =>
164 CInterface.peak_icv_PointCloud_GetPoints(
167 (nuint) (size * (
int) numPoints)));
170 .Select(np =>
new PointXYZI(np.x, np.y, np.z, np.intensity))
186 public static IEqualityComparer<PointCloudXYZI>
Comparer {
get; } =
new PointCloudEqualityComparer();
202 var cMatrix = matrix.ToCType();
203 DllHelper.ExecuteAndMapReturnCodes(() =>
204 CInterface.peak_icv_PointCloud_Transform(_handle, cMatrix,
205 ref pointCloud._handle));
222 DllHelper.ExecuteAndMapReturnCodes(() =>
223 CInterface.peak_icv_PointCloud_TransformToWorkspace(_handle, extrinsicParameters.ToCType(),
225 ref pointCloud._handle));
229 private static Handle CreateFromXYZImage(
XYZImage image,
Image intensityImage)
231 var handle =
new Handle();
232 DllHelper.ExecuteAndMapReturnCodes(() =>
233 CInterface.peak_icv_PointCloud_CreateFromXYZImageAndIntensityImage(out handle, image._handle,
234 intensityImage._handle));
238 private static Handle CreateFromUndistortedImage(
UndistortedImage undistortedDepthMap, Image intensityImage)
240 using var xyz =
new XYZImage(undistortedDepthMap);
241 return CreateFromXYZImage(xyz, intensityImage);
244 private static Handle LoadFromFile(
string filePath,
PixelFormat pixelFormat)
246 var handle =
new Handle();
247 DllHelper.ExecuteAndMapReturnCodes(() =>
248 CInterface.peak_icv_PointCloud_CreateFromFile(out handle,
249 PixelFormatToPointType(pixelFormat), Utils.ToUtf8(filePath)));
255 Backend.Types.peak_icv_point_xyzi[] pointsC = points.Select(point =>
256 new Backend.Types.peak_icv_point_xyzi
261 intensity = point.Intensity
264 var handle =
new Handle();
265 DllHelper.ExecuteAndMapReturnCodes(() =>
266 CInterface.peak_icv_PointCloud_CreateFromPoints(
267 out handle, pointsC, (nuint) pointsC.Length,
268 PixelFormatToPointType(pixelFormat)));
273 private static Backend.Types.peak_icv_point_type PixelFormatToPointType(
PixelFormat pixelFormat)
275 return pixelFormat
switch
277 PixelFormat.Mono8 => Backend.Types.peak_icv_point_type.PEAK_ICV_POINT_TYPE_XYZ_I8,
278 PixelFormat.Mono10 => Backend.Types.peak_icv_point_type.PEAK_ICV_POINT_TYPE_XYZ_I10,
279 PixelFormat.Mono12 => Backend.Types.peak_icv_point_type.PEAK_ICV_POINT_TYPE_XYZ_I12,
281 "Unsupported pixel format. Supported formats are Mono8, Mono10, and Mono12.")
285 private sealed class PointCloudEqualityComparer : IEqualityComparer<PointCloudXYZI>
289 if (ReferenceEquals(x, y))
294 if (ReferenceEquals(x,
null))
299 if (ReferenceEquals(y,
null))
310 var count = points.Count();