Zivid C++ API 2.9.0+4dbba385-1
Defining the Future of 3D Machine Vision
PointCloud.h
Go to the documentation of this file.
1
2
3/*******************************************************************************
4
5 * This file is part of the Zivid 3D Camera API
6
7 *
8
9 * Copyright 2015-2023 (C) Zivid AS
10
11 * All rights reserved.
12
13 *
14
15 * Zivid Software License, v1.0
16
17 *
18
19 * Redistribution and use in source and binary forms, with or without
20
21 * modification, are permitted provided that the following conditions are met:
22
23 *
24
25 * 1. Redistributions of source code must retain the above copyright notice,
26
27 * this list of conditions and the following disclaimer.
28
29 *
30
31 * 2. Redistributions in binary form must reproduce the above copyright notice,
32
33 * this list of conditions and the following disclaimer in the documentation
34
35 * and/or other materials provided with the distribution.
36
37 *
38
39 * 3. Neither the name of Zivid AS nor the names of its contributors may be used
40
41 * to endorse or promote products derived from this software without specific
42
43 * prior written permission.
44
45 *
46
47 * 4. This software, with or without modification, must not be used with any
48
49 * other 3D camera than from Zivid AS.
50
51 *
52
53 * 5. Any software provided in binary form under this license must not be
54
55 * reverse engineered, decompiled, modified and/or disassembled.
56
57 *
58
59 * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
60
61 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
62
63 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
64
65 * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
66
67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68
69 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
70
71 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
72
73 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74
75 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76
77 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78
79 *
80
81 * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
82
83 * Info: http://www.zivid.com
84
85 ******************************************************************************/
86
87
88
89#pragma once
90
91#include <Zivid/Matrix.h>
92#include "Zivid/Array2D.h"
94#include "Zivid/Image.h"
95#include "Zivid/Normal.h"
96#include "Zivid/Point.h"
98#include "Zivid/SNR.h"
99
100#include <iosfwd>
101#include <memory>
102#include <string>
103
104namespace Zivid
105{
115 {
116 public:
123 enum class Downsampling
124 {
125 by2x2,
126 by3x3,
127 by4x4,
128 };
129
132
134 ZIVID_CORE_EXPORT size_t width() const;
135
137 ZIVID_CORE_EXPORT size_t height() const;
138
141 ZIVID_CORE_EXPORT size_t size() const;
142
145
161
181
193
206
219
232
245
252
266
280
294
306 template<typename DataFormat>
308 {
309 static_assert(
310 HasCopyDataImplReturnArray2DTag<DataFormat>::value,
311 "The provided DataFormat is unsupported. Please refer to the documentation for "
312 "this method for the supported DataFormats.");
313 return copyDataImpl(ReturnArray2DTag<DataFormat>{});
314 }
315
379 template<typename DataFormat>
380 void copyData(DataFormat *destination) const
381 {
382 static_assert(
383 HasCopyDataImpl<DataFormat *>::value,
384 "The provided DataFormat is unsupported. Please refer to the documentation for "
385 "this method for the supported data formats.");
386 return copyDataImpl(destination);
387 }
388
391 ZIVID_CORE_EXPORT std::string toString() const;
392
398
426
435
436#ifndef NO_DOC
437 ZIVID_CORE_EXPORT class PointCloudImpl &getImpl();
438 ZIVID_CORE_EXPORT const class PointCloudImpl &getImpl() const;
439 ZIVID_CORE_EXPORT explicit PointCloud(std::shared_ptr<class PointCloudImpl> other);
440#endif
441
442 private:
443 template<class T>
444 struct ReturnArray2DTag
445 {};
446
447 template<typename... Args>
448 class HasCopyDataImplReturnArray2DTag
449 {
450 template<
451 typename C,
452 typename = decltype(std::declval<C>().copyDataImpl(std::declval<ReturnArray2DTag<Args>>()...))>
453 static std::true_type test(int);
454 template<typename C>
455 static std::false_type test(...);
456
457 public:
458 static constexpr bool value = decltype(test<PointCloud>(0))::value;
459 };
460
461 template<typename... Args>
462 class HasCopyDataImpl
463 {
464 template<typename C, typename = decltype(std::declval<C>().copyDataImpl(std::declval<Args>()...))>
465 static std::true_type test(int);
466 template<typename C>
467 static std::false_type test(...);
468
469 public:
470 static constexpr bool value = decltype(test<PointCloud>(0))::value;
471 };
472
473 ZIVID_CORE_EXPORT Array2D<PointXYZ> copyDataImpl(ReturnArray2DTag<PointXYZ> /*tag*/) const;
474 ZIVID_CORE_EXPORT Array2D<PointXYZW> copyDataImpl(ReturnArray2DTag<PointXYZW> /*tag*/) const;
475 ZIVID_CORE_EXPORT Array2D<PointZ> copyDataImpl(ReturnArray2DTag<PointZ> /*tag*/) const;
476 ZIVID_CORE_EXPORT Array2D<ColorRGBA> copyDataImpl(ReturnArray2DTag<ColorRGBA> /*tag*/) const;
477 ZIVID_CORE_EXPORT Array2D<ColorBGRA> copyDataImpl(ReturnArray2DTag<ColorBGRA> /*tag*/) const;
478 ZIVID_CORE_EXPORT Array2D<PointXYZColorRGBA> copyDataImpl(ReturnArray2DTag<PointXYZColorRGBA> /*tag*/) const;
479 ZIVID_CORE_EXPORT Array2D<PointXYZColorBGRA> copyDataImpl(ReturnArray2DTag<PointXYZColorBGRA> /*tag*/) const;
480 ZIVID_CORE_EXPORT Array2D<SNR> copyDataImpl(ReturnArray2DTag<SNR> /*tag*/) const;
481 ZIVID_CORE_EXPORT Array2D<NormalXYZ> copyDataImpl(ReturnArray2DTag<NormalXYZ> /*tag*/) const;
482 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZ *destination) const;
483 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZW *destination) const;
484 ZIVID_CORE_EXPORT void copyDataImpl(PointZ *destination) const;
485 ZIVID_CORE_EXPORT void copyDataImpl(ColorRGBA *destination) const;
486 ZIVID_CORE_EXPORT void copyDataImpl(ColorBGRA *destination) const;
487 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZColorRGBA *destination) const;
488 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZColorBGRA *destination) const;
489 ZIVID_CORE_EXPORT void copyDataImpl(SNR *destination) const;
490 ZIVID_CORE_EXPORT void copyDataImpl(NormalXYZ *destination) const;
491
492 std::shared_ptr<class PointCloudImpl> m_impl;
493 };
494
496 ZIVID_CORE_EXPORT std::ostream &operator<<(std::ostream &stream, const PointCloud &pointCloud);
497
498#ifndef NO_DOC
500 namespace Detail
501 {
502 ZIVID_CORE_EXPORT void waitUntilProcessingIsComplete(const PointCloud &pointCloud);
503 } // namespace Detail
504#endif
505
506} // namespace Zivid
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:101
Two-dimensional container of data
Definition: Array2D.h:119
A 2-dimensional image
Definition: Image.h:115
Point cloud with x, y, z, RGB color and SNR laid out on a 2D grid
Definition: PointCloud.h:115
ZIVID_CORE_EXPORT Array2D< PointXYZW > copyPointsXYZW() const
Array2D of point coordinates in 4D
ZIVID_CORE_EXPORT PointCloud & downsample(Downsampling downsampling)
Downsample the point cloud in-place
ZIVID_CORE_EXPORT Image< ColorRGBA > copyImageRGBA() const
Get point cloud colors as 8-bit RGBA image
void copyData(DataFormat *destination) const
Copy data in the specified DataFormat to a destination buffer
Definition: PointCloud.h:380
ZIVID_CORE_EXPORT Array2D< SNR > copySNRs() const
Array2D of SNR values
ZIVID_CORE_EXPORT PointCloud & transform(const Zivid::Matrix4x4 &matrix)
Transform the point cloud in-place by the given 4x4 transformation matrix
Downsampling
Option for downsampling
Definition: PointCloud.h:124
ZIVID_CORE_EXPORT Array2D< ColorRGBA > copyColorsRGBA() const
Array2D of point colors in 8-bit RGBA format
ZIVID_CORE_EXPORT size_t size() const
Get the size of the point cloud (total number of points)
ZIVID_CORE_EXPORT Array2D< PointXYZColorRGBA > copyPointsXYZColorsRGBA() const
Array2D of PointXYZColorRGBA
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of the point cloud
Array2D< DataFormat > copyData() const
Array2D with point cloud data using specified DataFormat
Definition: PointCloud.h:307
ZIVID_CORE_EXPORT PointCloud()
Create an empty point cloud
ZIVID_CORE_EXPORT Array2D< NormalXYZ > copyNormalsXYZ() const
Array2D of NormalXYZ
ZIVID_CORE_EXPORT size_t width() const
Get the width of the point cloud (number of columns)
ZIVID_CORE_EXPORT Array2D< PointXYZ > copyPointsXYZ() const
Array2D of point coordinates
ZIVID_CORE_EXPORT Array2D< PointXYZColorBGRA > copyPointsXYZColorsBGRA() const
Array2D of PointXYZColorBGRA
ZIVID_CORE_EXPORT Array2D< PointZ > copyPointsZ() const
Array2D of Z coordinates
ZIVID_CORE_EXPORT PointCloud downsampled(Downsampling downsampling) const
Get a downsampled point cloud
ZIVID_CORE_EXPORT bool isEmpty() const
Check if the point cloud is empty (contains zero points)
ZIVID_CORE_EXPORT Image< ColorBGRA > copyImageBGRA() const
Get point cloud colors as 8-bit BGRA image
ZIVID_CORE_EXPORT size_t height() const
Get the height of the point cloud (number of rows)
ZIVID_CORE_EXPORT Array2D< ColorBGRA > copyColorsBGRA() const
Array2D of point colors in 8-bit BGRA format
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:99
std::ostream & operator<<(std::ostream &stream, const Array2D< T > &array)
Serialize array information to a stream
Definition: Array2D.h:243