Zivid C++ API 2.14.0+e4a0c4a9-1
PointCloudExport.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
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
67 namespace FileFormat
68 {
73 class ZDF
74 {
75 public:
76 static constexpr const char *description{ "Zivid Data File" };
77 static constexpr const char *defaultExtension{ ".zdf" };
78 static constexpr bool canLoad{ true };
79
82 ZIVID_CORE_EXPORT explicit ZDF(const std::string &fileName);
83
85 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
86
88 ZIVID_CORE_EXPORT std::string toString() const;
89
90 private:
91 std::filesystem::path m_fileName;
92 };
93
99 class PLY
100 {
101 public:
102 static constexpr const char *description{ "PLY File" };
103 static constexpr const char *defaultExtension{ ".ply" };
104 static constexpr bool canLoad{ false };
105
107 enum class Layout
108 {
109 ordered,
111 };
112
118 ZIVID_CORE_EXPORT explicit PLY(const std::string &fileName);
119
125
127 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
128
131
134
136 ZIVID_CORE_EXPORT std::string toString() const;
137
138 private:
139 std::filesystem::path m_fileName;
140 Layout m_layout = Layout::ordered;
141 ColorSpace m_colorSpace = ColorSpace::sRGB;
142 };
143
149 class XYZ
150 {
151 public:
152 static constexpr const char *description{ "ASCII Points File" };
153 static constexpr const char *defaultExtension{ ".xyz" };
154 static constexpr bool canLoad{ false };
155
161 ZIVID_CORE_EXPORT explicit XYZ(const std::string &fileName);
162
167
169 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
170
173
175 ZIVID_CORE_EXPORT std::string toString() const;
176
177 private:
178 std::filesystem::path m_fileName;
179 ColorSpace m_colorSpace = ColorSpace::sRGB;
180 };
181
188 class PCD
189 {
190 public:
191 static constexpr const char *description{ "Point Cloud Data File" };
192 static constexpr const char *defaultExtension{ ".pcd" };
193 static constexpr bool canLoad{ false };
194
200 ZIVID_CORE_EXPORT explicit PCD(const std::string &fileName);
201
206
208 ZIVID_CORE_EXPORT const std::filesystem::path &fileName() const;
209
212
214 ZIVID_CORE_EXPORT std::string toString() const;
215
216 private:
217 std::filesystem::path m_fileName;
218 ColorSpace m_colorSpace = ColorSpace::sRGB;
219 };
220
221 using FrameFileFormats = std::tuple<ZDF, PLY, XYZ, PCD>;
222 } // namespace FileFormat
223
230 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::ZDF &specification);
231
239 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::PLY &specification);
240
249 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::XYZ &specification);
250
263 ZIVID_CORE_EXPORT void exportFrame(const Zivid::Frame &frame, const FileFormat::PCD &specification);
264 } // namespace Experimental::PointCloudExport
265} // namespace Zivid
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
Specification for saving frame in PCD (*.pcd) format.
Definition PointCloudExport.h:189
static constexpr const char * description
Definition PointCloudExport.h:191
ZIVID_CORE_EXPORT const std::filesystem::path & fileName() const
Get the file name.
static constexpr bool canLoad
Definition PointCloudExport.h:193
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 ColorSpace colorSpace() const
Get the color space of PCD specification.
static constexpr const char * defaultExtension
Definition PointCloudExport.h:192
Specification for saving frame in PLY (*.ply) format.
Definition PointCloudExport.h:100
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:103
static constexpr bool canLoad
Definition PointCloudExport.h:104
ZIVID_CORE_EXPORT ColorSpace colorSpace() const
Get the color space of PLY specification.
Layout
Layout for saving point cloud.
Definition PointCloudExport.h:108
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.
static constexpr const char * description
Definition PointCloudExport.h:102
Specification for saving frame in ASCII (*.xyz) format.
Definition PointCloudExport.h:150
static constexpr const char * description
Definition PointCloudExport.h:152
ZIVID_CORE_EXPORT const std::filesystem::path & fileName() const
Get the file name.
static constexpr bool canLoad
Definition PointCloudExport.h:154
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:153
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:74
ZIVID_CORE_EXPORT std::string toString() const
Get string representation of ZDF specification.
static constexpr bool canLoad
Definition PointCloudExport.h:78
static constexpr const char * description
Definition PointCloudExport.h:76
static constexpr const char * defaultExtension
Definition PointCloudExport.h:77
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:221
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.
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:84