Zivid C++ API 2.16.0+46cdaba6-1
UnorganizedPointCloud.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of the Zivid API
3 *
4 * Copyright 2015-2025 (C) Zivid AS
5 * All rights reserved.
6 *
7 * Zivid Software License, v1.0
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of Zivid AS nor the names of its contributors may be used
20 * to endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * 4. This software, with or without modification, must not be used with any
24 * other 3D camera than from Zivid AS.
25 *
26 * 5. Any software provided in binary form under this license must not be
27 * reverse engineered, decompiled, modified and/or disassembled.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
41 * Info: http://www.zivid.com
42 ******************************************************************************/
43
44#pragma once
45
46#include "Zivid/Array1D.h"
47#include "Zivid/Color.h"
49#include "Zivid/Matrix.h"
50#include "Zivid/Point.h"
51#include "Zivid/SNR.h"
52
53#include <iosfwd>
54#include <memory>
55#include <optional>
56#include <string>
57
58namespace Zivid
59{
72 {
73 public:
80
82 ZIVID_CORE_EXPORT size_t size() const;
83
88
92
121 ZIVID_CORE_EXPORT UnorganizedPointCloud voxelDownsampled(float voxelSize, int minPointsPerVoxel) const;
122
128
136
140
144 ZIVID_CORE_EXPORT std::optional<PointXYZ> centroid() const;
145
158
171
184
196
208
221
233 template<typename DataFormat>
235 {
236 static_assert(
237 HasCopyDataImplReturnArray1DTag<DataFormat>::value,
238 "The provided DataFormat is unsupported. Please refer to the documentation for "
239 "this method for the supported DataFormats.");
240 return copyDataImpl(ReturnArray1DTag<DataFormat>{});
241 }
242
288 template<typename DataFormat>
289 void copyData(DataFormat *destination) const
290 {
291 static_assert(
292 HasCopyDataImpl<DataFormat *>::value,
293 "The provided DataFormat is unsupported. Please refer to the documentation for "
294 "this method for the supported data formats.");
295 return copyDataImpl(destination);
296 }
297
309
312 ZIVID_CORE_EXPORT std::string toString() const;
313
314#ifndef NO_DOC
315 ZIVID_CORE_EXPORT class UnorganizedPointCloudImpl &getImpl();
316 ZIVID_CORE_EXPORT const class UnorganizedPointCloudImpl &getImpl() const;
317 ZIVID_CORE_EXPORT explicit UnorganizedPointCloud(std::shared_ptr<class UnorganizedPointCloudImpl> other);
318#endif
319
320 private:
321 template<class T>
322 struct ReturnArray1DTag
323 {};
324
325 template<typename... Args>
326 class HasCopyDataImplReturnArray1DTag
327 {
328 template<
329 typename C,
330 typename = decltype(std::declval<C>().copyDataImpl(std::declval<ReturnArray1DTag<Args>>()...))>
331 static std::true_type test(int);
332 template<typename C>
333 static std::false_type test(...);
334
335 public:
336 static constexpr bool value = decltype(test<UnorganizedPointCloud>(0))::value;
337 };
338
339 template<typename... Args>
340 class HasCopyDataImpl
341 {
342 template<typename C, typename = decltype(std::declval<C>().copyDataImpl(std::declval<Args>()...))>
343 static std::true_type test(int);
344 template<typename C>
345 static std::false_type test(...);
346
347 public:
348 static constexpr bool value = decltype(test<UnorganizedPointCloud>(0))::value;
349 };
350
351 ZIVID_CORE_EXPORT Array1D<PointXYZ> copyDataImpl(ReturnArray1DTag<PointXYZ> /*tag*/) const;
352 ZIVID_CORE_EXPORT Array1D<ColorRGBA> copyDataImpl(ReturnArray1DTag<ColorRGBA> /*tag*/) const;
353 ZIVID_CORE_EXPORT Array1D<ColorBGRA> copyDataImpl(ReturnArray1DTag<ColorBGRA> /*tag*/) const;
354 ZIVID_CORE_EXPORT Array1D<ColorRGBA_SRGB> copyDataImpl(ReturnArray1DTag<ColorRGBA_SRGB> /*tag*/) const;
355 ZIVID_CORE_EXPORT Array1D<ColorBGRA_SRGB> copyDataImpl(ReturnArray1DTag<ColorBGRA_SRGB> /*tag*/) const;
356 ZIVID_CORE_EXPORT Array1D<SNR> copyDataImpl(ReturnArray1DTag<SNR> /*tag*/) const;
357
358 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZ *destination) const;
359 ZIVID_CORE_EXPORT void copyDataImpl(ColorRGBA *destination) const;
360 ZIVID_CORE_EXPORT void copyDataImpl(ColorBGRA *destination) const;
361 ZIVID_CORE_EXPORT void copyDataImpl(ColorRGBA_SRGB *destination) const;
362 ZIVID_CORE_EXPORT void copyDataImpl(ColorBGRA_SRGB *destination) const;
363 ZIVID_CORE_EXPORT void copyDataImpl(SNR *destination) const;
364
365 std::shared_ptr<class UnorganizedPointCloudImpl> m_impl;
366 };
367
370 std::ostream &stream,
371 const UnorganizedPointCloud &unorganizedPointCloud);
372
373#ifndef NO_DOC
375 namespace Detail
376 {
377 ZIVID_CORE_EXPORT void waitUntilProcessingIsComplete(const UnorganizedPointCloud &unorganizedPointCloud);
378 } // namespace Detail
379#endif
380} // namespace Zivid
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
One-dimensional container of data.
Definition Array1D.h:72
Point cloud with x, y, z, RGB color and SNR laid out as a linear list of only valid points.
Definition UnorganizedPointCloud.h:72
ZIVID_CORE_EXPORT std::optional< PointXYZ > centroid() const
Get the centroid of the point cloud, i.e. average of all XYZ point positions.
ZIVID_CORE_EXPORT Array1D< SNR > copySNRs() const
Get the SNR data of every point.
ZIVID_CORE_EXPORT Array1D< ColorRGBA > copyColorsRGBA() const
Get the color data of every point on 8-bit RGBA format.
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of the point cloud.
ZIVID_CORE_EXPORT UnorganizedPointCloud clone() const
Returns a clone of the point cloud. The clone will include a copy of all of the point cloud data on t...
ZIVID_CORE_EXPORT UnorganizedPointCloud extended(const UnorganizedPointCloud &other) const
Create a new point cloud containing the combined data of this point cloud and another.
ZIVID_CORE_EXPORT UnorganizedPointCloud & center()
Translate the point cloud in-place so that its centroid lands at the origin (0,0,0)
ZIVID_CORE_EXPORT Array1D< ColorRGBA_SRGB > copyColorsRGBA_SRGB() const
Get the color data of every point on 8-bit RGBA format in the sRGB color space.
Array1D< DataFormat > copyData() const
Array1D with point cloud data using specified DataFormat.
Definition UnorganizedPointCloud.h:234
ZIVID_CORE_EXPORT UnorganizedPointCloud & transform(const Zivid::Matrix4x4 &matrix)
Transform the point cloud in-place by the given 4x4 transformation matrix.
ZIVID_CORE_EXPORT UnorganizedPointCloud voxelDownsampled(float voxelSize, int minPointsPerVoxel) const
Create a new point cloud that is a voxel downsampling of this point cloud.
void copyData(DataFormat *destination) const
Copy data in the specified DataFormat to a destination buffer.
Definition UnorganizedPointCloud.h:289
ZIVID_CORE_EXPORT size_t size() const
Get the size of the point cloud (total number of points)
ZIVID_CORE_EXPORT UnorganizedPointCloud transformed(const Zivid::Matrix4x4 &matrix) const
Transform the point cloud by the given 4x4 transformation matrix.
ZIVID_CORE_EXPORT UnorganizedPointCloud & extend(const UnorganizedPointCloud &other)
Extend this point cloud in-place by adding the points from another point cloud.
ZIVID_CORE_EXPORT Array1D< ColorBGRA > copyColorsBGRA() const
Get the color data of every point on 8-bit BGRA format.
ZIVID_CORE_EXPORT Array1D< PointXYZ > copyPointsXYZ() const
Get the XYZ data of every point.
ZIVID_CORE_EXPORT Array1D< ColorBGRA_SRGB > copyColorsBGRA_SRGB() const
Get the color data of every point on 8-bit BGRA format in the sRGB color space.
ZIVID_CORE_EXPORT UnorganizedPointCloud()
Create an empty point cloud.
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:84
ColorSRGB ColorRGBA_SRGB
Color with 8-bit red, green, blue and alpha channels in the sRGB color space.
Definition Color.h:79
std::ostream & operator<<(std::ostream &stream, const Array1D< T > &array)
Serialize array information to a stream.
Definition Array1D.h:183