61 # pragma warning(push)
62 # pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
71 static constexpr
size_t version{ 1 };
84 Settings2D(
const Settings2D &other);
87 Settings2D &operator=(
const Settings2D &other);
90 Settings2D(Settings2D &&other) noexcept;
93 Settings2D &operator=(Settings2D &&other) noexcept;
96 Settings2D() =
default;
99 static constexpr
bool isContainer{
true };
102 static constexpr
const char *path{
"" };
105 static constexpr
const char *name{
"Settings2D" };
108 static constexpr
const char *description{ R
"description(2D Capture settings)description" };
111 void set(
const std::string &fullPath,
const std::string &value);
114 std::string getString(
const std::string &fullPath)
const;
133 using ValueType = double;
136 static constexpr
bool isContainer{
false };
139 static constexpr
const char *path{
"Brightness" };
142 static constexpr
const char *name{
"Brightness" };
145 static constexpr
const char *description{
146 R
"description(Brightness controls the light output from the projector.
148 Brightness above 1.0 may be needed when the distance between the camera and the
149 scene is large, or in case of high levels of ambient lighting. Brightness above 1.0
150 is only supported on Zivid One Plus.
152 When brightness is above 1.0 the duty cycle of the camera (the percentage of time the
153 camera can capture frames) will be reduced. The lights in the projector can be lit for
154 at most 50% of the time during a 10 second period. This limitation is enforced automatically
155 by the camera. Calling capture2D when the duty cycle limit has been reached will cause
156 the camera to first wait (sleep) for a duration of time to cool down, before capture will
162 Brightness() = default;
165 explicit constexpr Brightness(ValueType value) noexcept(
166 std::is_nothrow_copy_constructible<ValueType>::value)
171 const ValueType &value()
const
177 Range<ValueType> range()
const
183 void setFromString(
const std::string &value)
185 m_value = std::stod(value);
191 return std::to_string(m_value);
195 bool operator==(
const Brightness &other)
const
197 return m_value == other.m_value;
201 bool operator!=(
const Brightness &other)
const
203 return m_value != other.m_value;
207 bool operator<(
const Brightness &other)
const
209 return m_value < other.m_value;
215 return m_value > other.m_value;
225 friend std::istream &operator>>(std::istream &stream,
Brightness &value)
228 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
233 ValueType m_value{ 1 };
241 using ValueType = std::chrono::microseconds;
244 static constexpr
bool isContainer{
false };
247 static constexpr
const char *path{
"ExposureTime" };
250 static constexpr
const char *name{
"ExposureTime" };
253 static constexpr
const char *description{ R
"description(Exposure time for the image.)description" };
260 std::is_nothrow_copy_constructible<ValueType>::value)
265 const ValueType &value()
const
273 return { ValueType{ 6500 }, ValueType{ 100000 } };
277 void setFromString(
const std::string &value)
279 m_value = ValueType{ std::stoll(value) };
285 return std::to_string(m_value.count());
291 return m_value == other.m_value;
297 return m_value != other.m_value;
303 return m_value < other.m_value;
309 return m_value > other.m_value;
313 friend std::ostream &
operator<<(std::ostream &stream,
const ExposureTime &value)
315 return stream << value.toString();
319 friend std::istream &operator>>(std::istream &stream,
ExposureTime &value)
322 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
338 static constexpr
bool isContainer{
false };
341 static constexpr
const char *path{
"Gain" };
344 static constexpr
const char *name{
"Gain" };
347 static constexpr
const char *description{ R
"description(Analog gain in the camera)description" };
353 explicit constexpr
Gain(
ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
370 void setFromString(
const std::string &value)
372 m_value = std::stod(value);
378 return std::to_string(m_value);
382 bool operator==(
const Gain &other)
const
384 return m_value == other.m_value;
388 bool operator!=(
const Gain &other)
const
390 return m_value != other.m_value;
394 bool operator<(
const Gain &other)
const
396 return m_value < other.m_value;
400 bool operator>(
const Gain &other)
const
402 return m_value > other.m_value;
406 friend std::ostream &
operator<<(std::ostream &stream,
const Gain &value)
412 friend std::istream &operator>>(std::istream &stream,
Gain &value)
415 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
431 static constexpr
bool isContainer{
false };
434 static constexpr
const char *path{
"Iris" };
437 static constexpr
const char *name{
"Iris" };
440 static constexpr
const char *description{
441 R
"description(Iris (aperture) setting for the camera)description"
448 explicit constexpr
Iris(
ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
453 const ValueType &value()
const
465 void setFromString(
const std::string &value)
467 m_value = std::stoull(value);
473 return std::to_string(m_value);
477 bool operator==(
const Iris &other)
const
479 return m_value == other.m_value;
483 bool operator!=(
const Iris &other)
const
485 return m_value != other.m_value;
489 bool operator<(
const Iris &other)
const
491 return m_value < other.m_value;
495 bool operator>(
const Iris &other)
const
497 return m_value > other.m_value;
501 friend std::ostream &
operator<<(std::ostream &stream,
const Iris &value)
503 return stream << value.toString();
507 friend std::istream &operator>>(std::istream &stream,
Iris &value)
510 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
518 template<typename T, typename std::enable_if<std::is_same<T, Settings2D::Brightness>::value,
int>::type = 0>
524 template<typename T, typename std::enable_if<std::is_same<T, Settings2D::ExposureTime>::value,
int>::type = 0>
527 return m_exposureTime;
530 template<typename T, typename std::enable_if<std::is_same<T, Settings2D::Gain>::value,
int>::type = 0>
536 template<typename T, typename std::enable_if<std::is_same<T, Settings2D::Iris>::value,
int>::type = 0>
542 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
548 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
551 return m_exposureTime;
554 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
560 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
581 throw std::out_of_range(
"Brightness{ " + std::to_string(value.
value()) +
" } is not in range ["
582 + std::to_string(value.
range().min()) +
", "
583 + std::to_string(value.
range().max()) +
"]");
586 m_brightness = value;
596 ExposureTime m_exposureTime{};
602 if(value.
value().count() < value.
range().min().count()
603 || value.
value().count() > value.
range().max().count())
605 throw std::out_of_range(
"ExposureTime{ " + std::to_string(value.
value().count())
606 +
" } is not in range [" + std::to_string(value.
range().min().count()) +
", "
607 + std::to_string(value.
range().max().count()) +
"]");
610 m_exposureTime = value;
614 const ExposureTime &exposureTime()
const
616 return m_exposureTime;
628 throw std::out_of_range(
"Gain{ " + std::to_string(value.
value()) +
" } is not in range ["
629 + std::to_string(value.
range().min()) +
", "
630 + std::to_string(value.
range().max()) +
"]");
637 const Gain &gain()
const
647 Settings2D &set(
const Iris &value)
649 if(value.value() < value.range().min() || value.value() > value.range().max())
651 throw std::out_of_range(
"Iris{ " + std::to_string(value.value()) +
" } is not in range ["
652 + std::to_string(value.range().min()) +
", "
653 + std::to_string(value.range().max()) +
"]");
660 const Iris &iris()
const
667 void forEach(
const F &f)
const
677 void forEach(
const F &f)
687 void traverseValues(
const F &f)
const
697 void traverseValues(
const F &f)
715 void setFromString(
const std::string &value);
718 friend std::istream &operator>>(std::istream &stream,
Settings2D &value)
721 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
729 bool operator!=(
const Settings2D &other)
const;
732 explicit Settings2D(
const std::string &fileName);
735 void save(
const std::string &fileName)
const;
738 void load(
const std::string &fileName);
743 struct Settings2D::Version<1>
752 # pragma warning(pop)
756 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
767 = decltype(declval<Zivid::Settings2D>().get<i>());