Zivid C++ API 2.14.0+e4a0c4a9-1
PointCloud.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of the Zivid API
3 *
4 * Copyright 2015-2024 (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/Array2D.h"
48#include "Zivid/Image.h"
49#include "Zivid/Matrix.h"
50#include "Zivid/Normal.h"
51#include "Zivid/Point.h"
53#include "Zivid/SNR.h"
54
55#include <iosfwd>
56#include <memory>
57#include <string>
58
59namespace Zivid
60{
61 class Frame;
62
81 {
82 public:
89 enum class Downsampling
90 {
91 by2x2,
92 by3x3,
93 by4x4,
94 };
95
98
100 ZIVID_CORE_EXPORT size_t width() const;
101
103 ZIVID_CORE_EXPORT size_t height() const;
104
107 ZIVID_CORE_EXPORT size_t size() const;
108
111
127
147
159
176
193
211
228
241
260
267
281
295
309
321 template<typename DataFormat>
323 {
324 static_assert(
325 HasCopyDataImplReturnArray2DTag<DataFormat>::value,
326 "The provided DataFormat is unsupported. Please refer to the documentation for "
327 "this method for the supported DataFormats.");
328 return copyDataImpl(ReturnArray2DTag<DataFormat>{});
329 }
330
398 template<typename DataFormat>
399 void copyData(DataFormat *destination) const
400 {
401 static_assert(
402 HasCopyDataImpl<DataFormat *>::value,
403 "The provided DataFormat is unsupported. Please refer to the documentation for "
404 "this method for the supported data formats.");
405 return copyDataImpl(destination);
406 }
407
410 ZIVID_CORE_EXPORT std::string toString() const;
411
417
448
457
469
470#ifndef NO_DOC
471 ZIVID_CORE_EXPORT class PointCloudImpl &getImpl();
472 ZIVID_CORE_EXPORT const class PointCloudImpl &getImpl() const;
473 ZIVID_CORE_EXPORT explicit PointCloud(std::shared_ptr<class PointCloudImpl> other);
474#endif
475
476 private:
477 template<class T>
478 struct ReturnArray2DTag
479 {};
480
481 template<typename... Args>
482 class HasCopyDataImplReturnArray2DTag
483 {
484 template<
485 typename C,
486 typename = decltype(std::declval<C>().copyDataImpl(std::declval<ReturnArray2DTag<Args>>()...))>
487 static std::true_type test(int);
488 template<typename C>
489 static std::false_type test(...);
490
491 public:
492 static constexpr bool value = decltype(test<PointCloud>(0))::value;
493 };
494
495 template<typename... Args>
496 class HasCopyDataImpl
497 {
498 template<typename C, typename = decltype(std::declval<C>().copyDataImpl(std::declval<Args>()...))>
499 static std::true_type test(int);
500 template<typename C>
501 static std::false_type test(...);
502
503 public:
504 static constexpr bool value = decltype(test<PointCloud>(0))::value;
505 };
506
507 ZIVID_CORE_EXPORT Array2D<PointXYZ> copyDataImpl(ReturnArray2DTag<PointXYZ> /*tag*/) const;
508 ZIVID_CORE_EXPORT Array2D<PointXYZW> copyDataImpl(ReturnArray2DTag<PointXYZW> /*tag*/) const;
509 ZIVID_CORE_EXPORT Array2D<PointZ> copyDataImpl(ReturnArray2DTag<PointZ> /*tag*/) const;
510 ZIVID_CORE_EXPORT Array2D<ColorRGBA> copyDataImpl(ReturnArray2DTag<ColorRGBA> /*tag*/) const;
511 ZIVID_CORE_EXPORT Array2D<ColorBGRA> copyDataImpl(ReturnArray2DTag<ColorBGRA> /*tag*/) const;
512 ZIVID_CORE_EXPORT Array2D<ColorSRGB> copyDataImpl(ReturnArray2DTag<ColorSRGB> /*tag*/) const;
513 ZIVID_CORE_EXPORT Array2D<PointXYZColorRGBA> copyDataImpl(ReturnArray2DTag<PointXYZColorRGBA> /*tag*/) const;
514 ZIVID_CORE_EXPORT Array2D<PointXYZColorBGRA> copyDataImpl(ReturnArray2DTag<PointXYZColorBGRA> /*tag*/) const;
515 ZIVID_CORE_EXPORT Array2D<SNR> copyDataImpl(ReturnArray2DTag<SNR> /*tag*/) const;
516 ZIVID_CORE_EXPORT Array2D<NormalXYZ> copyDataImpl(ReturnArray2DTag<NormalXYZ> /*tag*/) const;
517 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZ *destination) const;
518 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZW *destination) const;
519 ZIVID_CORE_EXPORT void copyDataImpl(PointZ *destination) const;
520 ZIVID_CORE_EXPORT void copyDataImpl(ColorRGBA *destination) const;
521 ZIVID_CORE_EXPORT void copyDataImpl(struct ColorRGBAf *destination) const;
522 ZIVID_CORE_EXPORT void copyDataImpl(ColorBGRA *destination) const;
523 ZIVID_CORE_EXPORT void copyDataImpl(ColorSRGB *destination) const;
524 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZColorRGBA *destination) const;
525 ZIVID_CORE_EXPORT void copyDataImpl(PointXYZColorBGRA *destination) const;
526 ZIVID_CORE_EXPORT void copyDataImpl(SNR *destination) const;
527 ZIVID_CORE_EXPORT void copyDataImpl(NormalXYZ *destination) const;
528
529 std::shared_ptr<class PointCloudImpl> m_impl;
530 };
531
533 ZIVID_CORE_EXPORT std::ostream &operator<<(std::ostream &stream, const PointCloud &pointCloud);
534
535#ifndef NO_DOC
537 namespace Detail
538 {
539 ZIVID_CORE_EXPORT void waitUntilProcessingIsComplete(const PointCloud &pointCloud);
540 } // namespace Detail
541#endif
542
543} // namespace Zivid
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
Two-dimensional container of data.
Definition Array2D.h:83
A 2-dimensional image.
Definition Image.h:85
Point cloud with x, y, z, RGB color and SNR laid out on a 2D grid.
Definition PointCloud.h:81
ZIVID_CORE_EXPORT Array2D< PointXYZW > copyPointsXYZW() const
Array2D of point coordinates in 4D.
ZIVID_CORE_EXPORT PointCloud 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 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:399
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:90
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:322
ZIVID_CORE_EXPORT Image< ColorSRGB > copyImageSRGB() const
Get point cloud colors as 8-bit RGB image in the sRGB color space.
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< ColorSRGB > copyColorsSRGB() const
Array2D of point colors in 8-bit RGBA format in the sRGB color space.
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:84
std::ostream & operator<<(std::ostream &stream, const Array2D< T > &array)
Serialize array information to a stream.
Definition Array2D.h:283