Zivid C++ API 2.14.0+e4a0c4a9-1
SettingsInfo.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/CameraInfo.h>
49#include <Zivid/Range.h>
50#include <Zivid/Resolution.h>
51#include <Zivid/Settings.h>
52#include <Zivid/Settings2D.h>
53
54#define ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(T) ZIVID_CORE_EXPORT T defaultValue(Tag<T> tag, const CameraInfo &cameraInfo)
55
56#define ZIVID_DETAIL_CAMERA_VALID_VALUES(T) \
57 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(T); \
58 ZIVID_CORE_EXPORT std::set<T::ValueType> validValues(Tag<T> tag, const CameraInfo &cameraInfo)
59
60#define ZIVID_DETAIL_CAMERA_VALID_RANGE(T) \
61 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(T); \
62 ZIVID_CORE_EXPORT Range<T::ValueType> validRange(Tag<T> tag, const CameraInfo &cameraInfo)
63
64namespace Zivid
65{
66#ifndef NO_DOC
68 namespace Detail
69 {
70 template<typename T>
71 using Tag = TypeTraits::TypeIdentity<T>;
72
73 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::Color);
74 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::Acquisitions);
75 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::Processing::Filters::Reflection::Removal::Mode);
76 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::Extents);
77 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::PointO);
78 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::PointA);
79 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::PointB);
80 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Depth::Range);
81 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings2D::Acquisitions);
82
83 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::Aperture);
84 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::Brightness);
85 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::ExposureTime);
86 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::Gain);
87 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Balance::Blue);
88 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Balance::Green);
89 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Balance::Red);
90 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Gamma);
92 Settings::Processing::Filters::Experimental::ContrastDistortion::Correction::Strength);
93 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Cluster::Removal::MinArea);
94 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Cluster::Removal::MaxNeighborDistance);
96 Settings::Processing::Filters::Experimental::ContrastDistortion::Removal::Threshold);
97 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Hole::Repair::Strictness);
98 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Hole::Repair::HoleSize);
99 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Noise::Removal::Threshold);
100 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Outlier::Removal::Threshold);
101 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Smoothing::Gaussian::Sigma);
102 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::Aperture);
103 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::Brightness);
104 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::ExposureTime);
105 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::Gain);
106 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Balance::Blue);
107 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Balance::Green);
108 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Balance::Red);
109 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Gamma);
110 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings2D::Processing::Color::Experimental::Mode);
111 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings2D::Sampling::Pixel);
112 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings2D::Sampling::Color);
113
114 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Diagnostics::Enabled);
115 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Engine);
116 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Sampling::Pixel);
117 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Sampling::Color);
118 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Resampling::Mode);
119 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Color::Experimental::Mode);
121 Settings::Processing::Filters::Experimental::ContrastDistortion::Correction::Enabled);
122 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Cluster::Removal::Enabled);
124 Settings::Processing::Filters::Experimental::ContrastDistortion::Removal::Enabled);
125 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Hole::Repair::Enabled);
126 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Noise::Removal::Enabled);
127 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Noise::Suppression::Enabled);
128 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Noise::Repair::Enabled);
129 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Outlier::Removal::Enabled);
130 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Reflection::Removal::Enabled);
131 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Reflection::Removal::Mode);
132 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Smoothing::Gaussian::Enabled);
133 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::RegionOfInterest::Depth::Enabled);
134 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::RegionOfInterest::Box::Enabled);
135
136 class DefaultDataModelSetter
137 {
138 const CameraInfo &m_cameraInfo;
139
140 public:
141 DefaultDataModelSetter(const CameraInfo &cameraInfo)
142 : m_cameraInfo(cameraInfo)
143 {}
144
145 DefaultDataModelSetter(const DefaultDataModelSetter &) = delete;
146 DefaultDataModelSetter(DefaultDataModelSetter &&) = delete;
147 DefaultDataModelSetter &operator=(const DefaultDataModelSetter &) = delete;
148 DefaultDataModelSetter &operator=(DefaultDataModelSetter &&) = delete;
149
150 template<typename T>
151 void operator()(T &dataModelNode) const;
152 };
153
154 template<typename T, typename std::enable_if_t<T::nodeType == DataModel::NodeType::group, bool> = true>
155 T defaultValue(Tag<T> /* tag */, const CameraInfo &cameraInfo)
156 {
157 T group;
158 group.forEach(DefaultDataModelSetter(cameraInfo));
159 return group;
160 }
161
162 template<typename T>
163 void DefaultDataModelSetter::operator()(T &dataModelNode) const
164 {
165 dataModelNode = defaultValue(Tag<T>{}, m_cameraInfo);
166 }
167
168 ZIVID_CORE_EXPORT void validateSettings(const Settings &settings, const CameraInfo &cameraInfo);
169 ZIVID_CORE_EXPORT void validateSettings(const Settings2D &settings, const CameraInfo &cameraInfo);
170 } // namespace Detail
171#endif
172
173 namespace Experimental
174 {
175 namespace SettingsInfo
176 {
177 template<typename T>
178 T defaultValue(const CameraInfo &cameraInfo)
179 {
180 return Detail::defaultValue(Detail::Tag<T>{}, cameraInfo);
181 }
182
183 template<typename T>
184 std::set<typename T::ValueType> validValues(const CameraInfo &cameraInfo)
185 {
186 return Detail::validValues(Detail::Tag<T>{}, cameraInfo);
187 }
188
189 template<typename T, typename Ret = Range<typename T::ValueType>>
190 Ret validRange(const CameraInfo &cameraInfo)
191 {
192 return Detail::validRange(Detail::Tag<T>{}, cameraInfo);
193 }
194
207 ZIVID_CORE_EXPORT Resolution resolution(const CameraInfo &cameraInfo, const Settings &settings);
208 } // namespace SettingsInfo
209 } // namespace Experimental
210} // namespace Zivid
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
#define ZIVID_DETAIL_CAMERA_VALID_RANGE(T)
Definition SettingsInfo.h:60
#define ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(T)
Definition SettingsInfo.h:54
#define ZIVID_DETAIL_CAMERA_VALID_VALUES(T)
Definition SettingsInfo.h:56
Information about camera model, serial number etc.
Definition CameraInfo.h:78
Class describing a resolution with a width and a height.
Definition Resolution.h:56
Settings used when capturing a 3D capture or 2D+3D capture with a Zivid camera.
Definition Settings.h:81
T defaultValue(const CameraInfo &cameraInfo)
Definition SettingsInfo.h:178
ZIVID_CORE_EXPORT Resolution resolution(const CameraInfo &cameraInfo, const Settings &settings)
Returns the resolution of captured frames according to the provided camera information and settings.
Ret validRange(const CameraInfo &cameraInfo)
Definition SettingsInfo.h:190
std::set< typename T::ValueType > validValues(const CameraInfo &cameraInfo)
Definition SettingsInfo.h:184
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:84