Zivid C++ API 2.13.1+18e79e79-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::Acquisitions);
74 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::Processing::Filters::Reflection::Removal::Mode);
75 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::Extents);
76 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::PointO);
77 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::PointA);
78 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Box::PointB);
79 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings::RegionOfInterest::Depth::Range);
80 ZIVID_DETAIL_CAMERA_DEFAULT_VALUE(Settings2D::Acquisitions);
81
82 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::Aperture);
83 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::Brightness);
84 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::ExposureTime);
85 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Acquisition::Gain);
86 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Balance::Blue);
87 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Balance::Green);
88 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Balance::Red);
89 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Color::Gamma);
91 Settings::Processing::Filters::Experimental::ContrastDistortion::Correction::Strength);
92 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Cluster::Removal::MinArea);
93 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Cluster::Removal::MaxNeighborDistance);
95 Settings::Processing::Filters::Experimental::ContrastDistortion::Removal::Threshold);
96 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Hole::Repair::Strictness);
97 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Hole::Repair::HoleSize);
98 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Noise::Removal::Threshold);
99 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Outlier::Removal::Threshold);
100 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings::Processing::Filters::Smoothing::Gaussian::Sigma);
101 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::Aperture);
102 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::Brightness);
103 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::ExposureTime);
104 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Acquisition::Gain);
105 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Balance::Blue);
106 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Balance::Green);
107 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Balance::Red);
108 ZIVID_DETAIL_CAMERA_VALID_RANGE(Settings2D::Processing::Color::Gamma);
109 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings2D::Sampling::Pixel);
110 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings2D::Sampling::Color);
111
112 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Diagnostics::Enabled);
113 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Engine);
114 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Sampling::Pixel);
115 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Sampling::Color);
116 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Resampling::Mode);
117 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Color::Experimental::Mode);
119 Settings::Processing::Filters::Experimental::ContrastDistortion::Correction::Enabled);
120 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Cluster::Removal::Enabled);
122 Settings::Processing::Filters::Experimental::ContrastDistortion::Removal::Enabled);
123 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Hole::Repair::Enabled);
124 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Noise::Removal::Enabled);
125 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Noise::Suppression::Enabled);
126 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Noise::Repair::Enabled);
127 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Outlier::Removal::Enabled);
128 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Reflection::Removal::Enabled);
129 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Reflection::Removal::Mode);
130 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::Processing::Filters::Smoothing::Gaussian::Enabled);
131 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::RegionOfInterest::Depth::Enabled);
132 ZIVID_DETAIL_CAMERA_VALID_VALUES(Settings::RegionOfInterest::Box::Enabled);
133
134 class DefaultDataModelSetter
135 {
136 const CameraInfo &m_cameraInfo;
137
138 public:
139 DefaultDataModelSetter(const CameraInfo &cameraInfo)
140 : m_cameraInfo(cameraInfo)
141 {}
142
143 DefaultDataModelSetter(const DefaultDataModelSetter &) = delete;
144 DefaultDataModelSetter(DefaultDataModelSetter &&) = delete;
145 DefaultDataModelSetter &operator=(const DefaultDataModelSetter &) = delete;
146 DefaultDataModelSetter &operator=(DefaultDataModelSetter &&) = delete;
147
148 template<typename T>
149 void operator()(T &dataModelNode) const;
150 };
151
152 template<typename T, typename std::enable_if<T::nodeType == DataModel::NodeType::group, bool>::type = true>
153 T defaultValue(Tag<T> /* tag */, const CameraInfo &cameraInfo)
154 {
155 T group;
156 group.forEach(DefaultDataModelSetter(cameraInfo));
157 return group;
158 }
159
160 template<typename T>
161 void DefaultDataModelSetter::operator()(T &dataModelNode) const
162 {
163 dataModelNode = defaultValue(Tag<T>{}, m_cameraInfo);
164 }
165 } // namespace Detail
166#endif
167
168 namespace Experimental
169 {
170 namespace SettingsInfo
171 {
172 template<typename T>
173 T defaultValue(const CameraInfo &cameraInfo)
174 {
175 return Detail::defaultValue(Detail::Tag<T>{}, cameraInfo);
176 }
177
178 template<typename T>
179 std::set<typename T::ValueType> validValues(const CameraInfo &cameraInfo)
180 {
181 return Detail::validValues(Detail::Tag<T>{}, cameraInfo);
182 }
183
184 template<typename T, typename Ret = Range<typename T::ValueType>>
185 Ret validRange(const CameraInfo &cameraInfo)
186 {
187 return Detail::validRange(Detail::Tag<T>{}, cameraInfo);
188 }
189
190 ZIVID_CORE_EXPORT Resolution resolution(const CameraInfo &cameraInfo, const Settings &settings);
191 } // namespace SettingsInfo
192 } // namespace Experimental
193} // 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:79
Class describing a resolution with a width and a height.
Definition Resolution.h:56
Settings used when capturing with a Zivid camera.
Definition Settings.h:80
T defaultValue(const CameraInfo &cameraInfo)
Definition SettingsInfo.h:173
ZIVID_CORE_EXPORT Resolution resolution(const CameraInfo &cameraInfo, const Settings &settings)
Ret validRange(const CameraInfo &cameraInfo)
Definition SettingsInfo.h:185
std::set< typename T::ValueType > validValues(const CameraInfo &cameraInfo)
Definition SettingsInfo.h:179
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:56