Zivid C++ API 2.15.0+5fcc365b-1
PointCloudExport.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
47
48#include <filesystem>
49#include <string>
50
51namespace Zivid
52{
53 class Frame;
54
55 namespace Experimental::PointCloudExport
56 {
61 enum class ColorSpace
62 {
63 sRGB,
65 };
66
71 enum class IncludeNormals
72 {
73 no,
74 yes,
75 };
76
77 namespace FileFormat
78 {
83 class ZDF
84 {
85 public:
86 static constexpr const char *description{ "Zivid Data File" };
87 static constexpr const char *defaultExtension{ ".zdf" };
88 static constexpr bool canLoad{ true };
89
92 ZIVID_CORE_EXPORT explicit ZDF(const std::string &fileName);
93
95 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
96
98 ZIVID_CORE_EXPORT std::string toString() const;
99
100 private:
101 std::filesystem::path m_fileName;
102 };
103
109 class PLY
110 {
111 public:
112 static constexpr const char *description{ "PLY File" };
113 static constexpr const char *defaultExtension{ ".ply" };
114 static constexpr bool canLoad{ false };
115
117 enum class Layout
118 {
119 ordered,
121 };
122
128 ZIVID_CORE_EXPORT explicit PLY(const std::string &fileName);
129
138
146
148 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
149
152
155
158
160 ZIVID_CORE_EXPORT std::string toString() const;
161
162 private:
163 std::filesystem::path m_fileName;
164 Layout m_layout = Layout::ordered;
165 ColorSpace m_colorSpace = ColorSpace::sRGB;
166 IncludeNormals m_includeNormals = IncludeNormals::no;
167 };
168
174 class XYZ
175 {
176 public:
177 static constexpr const char *description{ "ASCII Points File" };
178 static constexpr const char *defaultExtension{ ".xyz" };
179 static constexpr bool canLoad{ false };
180
186 ZIVID_CORE_EXPORT explicit XYZ(const std::string &fileName);
187
192
194 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
195
198
200 ZIVID_CORE_EXPORT std::string toString() const;
201
202 private:
203 std::filesystem::path m_fileName;
204 ColorSpace m_colorSpace = ColorSpace::sRGB;
205 };
206
213 class PCD
214 {
215 public:
216 static constexpr const char *description{ "Point Cloud Data File" };
217 static constexpr const char *defaultExtension{ ".pcd" };
218 static constexpr bool canLoad{ false };
219
225 ZIVID_CORE_EXPORT explicit PCD(const std::string &fileName);
226
234
241
243 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
244
247
250
252 ZIVID_CORE_EXPORT std::string toString() const;
253
254 private:
255 std::filesystem::path m_fileName;
256 ColorSpace m_colorSpace = ColorSpace::sRGB;
257 IncludeNormals m_includeNormals = IncludeNormals::no;
258 };
259
260 using FrameFileFormats = std::tuple<ZDF, PLY, XYZ, PCD>;
261 } // namespace FileFormat
262
269 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::ZDF &specification);
270
278 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::PLY &specification);
279
288 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::XYZ &specification);
289
302 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::PCD &specification);
303 } // namespace Experimental::PointCloudExport
304} // namespace Zivid
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
Specification for saving frame in PCD (*.pcd) format.
Definition PointCloudExport.h:214
static constexpr const char * description
Definition PointCloudExport.h:216
ZIVID_CORE_EXPORT const std::filesystem::path & fileName() const
Get the file name.
static constexpr bool canLoad
Definition PointCloudExport.h:218
ZIVID_CORE_EXPORT PCD(const std::string &fileName, ColorSpace colorSpace, IncludeNormals includeNormals)
Create PCD specification with file name, color space and normals.
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of PCD specification.
ZIVID_CORE_EXPORT PCD(const std::string &fileName)
Create PCD specification with file name.
ZIVID_CORE_EXPORT PCD(const std::string &fileName, ColorSpace colorSpace)
Create PCD specification with file name and color space.
ZIVID_CORE_EXPORT IncludeNormals includeNormals() const
Get if normals are included in PCD specification.
ZIVID_CORE_EXPORT ColorSpace colorSpace() const
Get the color space of PCD specification.
static constexpr const char * defaultExtension
Definition PointCloudExport.h:217
Specification for saving frame in PLY (*.ply) format.
Definition PointCloudExport.h:110
ZIVID_CORE_EXPORT PLY(const std::string &fileName, Layout layout, ColorSpace colorSpace)
Create PLY specification with file name, layout, and color space.
ZIVID_CORE_EXPORT PLY(const std::string &fileName)
Create PLY specification with file name.
ZIVID_CORE_EXPORT const std::filesystem::path & fileName() const
Get the file name.
static constexpr const char * defaultExtension
Definition PointCloudExport.h:113
static constexpr bool canLoad
Definition PointCloudExport.h:114
ZIVID_CORE_EXPORT IncludeNormals includeNormals() const
Get if normals are included in PLY specification.
ZIVID_CORE_EXPORT ColorSpace colorSpace() const
Get the color space of PLY specification.
Layout
Layout for saving point cloud.
Definition PointCloudExport.h:118
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of PLY specification.
ZIVID_CORE_EXPORT Layout layout() const
Get the layout of PLY specification.
ZIVID_CORE_EXPORT PLY(const std::string &fileName, Layout layout, ColorSpace colorSpace, IncludeNormals includeNormals)
Create PLY specification with file name, layout, color space and normals.
static constexpr const char * description
Definition PointCloudExport.h:112
Specification for saving frame in ASCII (*.xyz) format.
Definition PointCloudExport.h:175
static constexpr const char * description
Definition PointCloudExport.h:177
ZIVID_CORE_EXPORT const std::filesystem::path & fileName() const
Get the file name.
static constexpr bool canLoad
Definition PointCloudExport.h:179
ZIVID_CORE_EXPORT XYZ(const std::string &fileName, ColorSpace colorSpace)
Create XYZ specification with file name and color space.
static constexpr const char * defaultExtension
Definition PointCloudExport.h:178
ZIVID_CORE_EXPORT XYZ(const std::string &fileName)
Create XYZ specification with file name.
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of XYZ specification.
ZIVID_CORE_EXPORT ColorSpace colorSpace() const
Get the color space of XYZ specification.
Specification for saving frame in ZDF (*.zdf) format.
Definition PointCloudExport.h:84
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of ZDF specification.
static constexpr bool canLoad
Definition PointCloudExport.h:88
static constexpr const char * description
Definition PointCloudExport.h:86
static constexpr const char * defaultExtension
Definition PointCloudExport.h:87
ZIVID_CORE_EXPORT const std::filesystem::path & fileName() const
Get the file name.
ZIVID_CORE_EXPORT ZDF(const std::string &fileName)
Create ZDF specification with file name.
A frame captured by a Zivid camera.
Definition Frame.h:69
std::tuple< ZDF, PLY, XYZ, PCD > FrameFileFormats
Definition PointCloudExport.h:260
ColorSpace
Color space to use when saving frame.
Definition PointCloudExport.h:62
ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::ZDF &specification)
Save frame to ZDF file.
IncludeNormals
Include normals in the exported file.
Definition PointCloudExport.h:72
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:84