IDS peak AFL v2.1.0
Loading...
Searching...
No Matches
peak_afl_brightness_algorithm.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
11
13
14#include <memory>
15
16namespace peak
17{
18namespace pipeline
19{
20namespace modules
21{
22namespace autofeature
23{
42
55PEAK_COMMON_NO_DISCARD inline std::string ToString(BrightnessAnalysisAlgorithm algorithm)
56{
57 if (algorithm == BrightnessAnalysisAlgorithm::Mean)
58 {
59 return "Mean";
60 }
62 {
63 return "Median";
64 }
65
67 "The given brightness algorithm is unknown!", PEAK_AFL_STATUS_INVALID_PARAMETER);
68}
69
88inline std::ostream& operator<<(std::ostream& os, BrightnessAnalysisAlgorithm algorithm)
89{
90 return os << ToString(algorithm);
91}
92
93namespace features
94{
95namespace detail
96{
97PEAK_COMMON_NO_DISCARD inline BrightnessAnalysisAlgorithm ToBrightnessAnalysisAlgorithm(const std::string& algorithm)
98{
99 if (algorithm == "Median")
100 {
102 }
103 if (algorithm == "Mean")
104 {
106 }
107
109 "The given brightness algorithm " + algorithm + " is unknown!", PEAK_AFL_STATUS_INVALID_PARAMETER);
110}
111
112PEAK_COMMON_NO_DISCARD inline peak_afl_controller_brightness_algorithm ToCType(BrightnessAnalysisAlgorithm algorithm)
113{
115 {
117 }
118 if (algorithm == BrightnessAnalysisAlgorithm::Mean)
119 {
121 }
122
123 throw peak::afl::error::InternalErrorException("The given brightness algorithm is unknown!", PEAK_AFL_STATUS_ERROR);
124}
125
126PEAK_COMMON_NO_DISCARD inline BrightnessAnalysisAlgorithm ToBrightnessAnalysisAlgorithm(
128{
130 {
132 }
134 {
136 }
137
138 throw peak::afl::error::InternalErrorException("The given brightness algorithm is unknown!", PEAK_AFL_STATUS_ERROR);
139}
140} // namespace detail
141
170class BrightnessAlgorithm : public IFeature<BrightnessAnalysisAlgorithm>
171{
172public:
185 explicit BrightnessAlgorithm(std::shared_ptr<peak::afl::Controller> controller)
186 : m_controller{ std::move(controller) }
187 {}
188
208 void Set(const BrightnessAnalysisAlgorithm& value) override
209 {
210 m_controller->SetBrightnessAlgorithm(detail::ToCType(value));
211 }
212
229 PEAK_COMMON_NO_DISCARD BrightnessAnalysisAlgorithm Get() const override
230 {
231 return detail::ToBrightnessAnalysisAlgorithm(m_controller->GetBrightnessAlgorithm());
232 }
233
249 {
250 archive.SetString("BrightnessAlgorithm", ToString(Get()));
251 }
252
269 {
270 Set(detail::ToBrightnessAnalysisAlgorithm(archive.GetString("BrightnessAlgorithm")));
271 }
272
273private:
281 std::shared_ptr<peak::afl::Controller> m_controller;
282};
283} // namespace features
284} // namespace autofeature
285} // namespace modules
286} // namespace pipeline
287} // namespace peak
The exception thrown for passing an invalid parameter to a function.
Definition peak_afl.hpp:436
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:54
virtual std::string GetString(const std::string &key) const =0
Retrieves a string value by key.
virtual void SetString(const std::string &key, const std::string &value)=0
Stores a UTF-8 string.
void Set(const BrightnessAnalysisAlgorithm &value) override
Sets the brightness analysis algorithm.
Definition peak_afl_brightness_algorithm.hpp:208
BrightnessAlgorithm(std::shared_ptr< peak::afl::Controller > controller)
Constructs a BrightnessAlgorithm feature with the specified controller.
Definition peak_afl_brightness_algorithm.hpp:185
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current brightness algorithm to an archive.
Definition peak_afl_brightness_algorithm.hpp:248
BrightnessAnalysisAlgorithm Get() const override
Gets the current brightness analysis algorithm.
Definition peak_afl_brightness_algorithm.hpp:229
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes the brightness algorithm from an archive.
Definition peak_afl_brightness_algorithm.hpp:268
Base interface for auto feature implementations.
Definition peak_afl_ifeature.hpp:55
peak_afl_controller_brightness_algorithm
Brightness calculation algorithms.
Definition peak_afl.h:769
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_ALGORITHM_MEAN
Mean-based brightness calculation.
Definition peak_afl.h:790
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_ALGORITHM_MEDIAN
Median-based brightness calculation.
Definition peak_afl.h:779
@ PEAK_AFL_STATUS_INVALID_PARAMETER
Invalid parameter provided.
Definition peak_afl.h:416
@ PEAK_AFL_STATUS_ERROR
General error occurred.
Definition peak_afl.h:396
std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:74
BrightnessAnalysisAlgorithm
Brightness analysis algorithm enumeration.
Definition peak_afl_brightness_algorithm.hpp:36
@ Mean
Mean-based brightness calculation - uses the average value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:40
@ Median
Median-based brightness calculation - uses the median value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:38
Interface definitions and implementations for individual module types used within a pipeline.
Definition peak_afl_generic_auto_brightness.hpp:35
Interfaces and implementations for defining and controlling data processing pipelines.
Definition peak_afl_generic_auto_brightness.hpp:33