IDS peak AFL v1.8.0
Loading...
Searching...
No Matches
peak_afl_brightness_algorithm.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <peak_afl/peak_afl.hpp>
15
17
18#include <memory>
19
20namespace peak
21{
22namespace pipeline
23{
24namespace modules
25{
26namespace autofeature
27{
28
47
61{
62 if (algorithm == BrightnessAnalysisAlgorithm::Mean)
63 {
64 return "Mean";
65 }
67 {
68 return "Median";
69 }
70
71 throw peak::common::InvalidParameterException("The given brightness algorithm is unknown!");
72}
73
92inline std::ostream& operator<<(std::ostream& os, BrightnessAnalysisAlgorithm algorithm)
93{
94 return os << ToString(algorithm);
95}
96
97namespace features
98{
99
100namespace detail
101{
102
103PEAK_COMMON_NO_DISCARD inline BrightnessAnalysisAlgorithm ToBrightnessAnalysisAlgorithm(const std::string& algorithm)
104{
105 if (algorithm == "Median")
106 {
108 }
109 if (algorithm == "Mean")
110 {
112 }
113
114 throw peak::common::InvalidParameterException("The given brightness algorithm " + algorithm + " is unknown!");
115}
116
118{
120 {
122 }
123 if (algorithm == BrightnessAnalysisAlgorithm::Mean)
124 {
126 }
127
128 throw peak::common::InternalErrorException("The given brightness algorithm is unknown!");
129}
130
131PEAK_COMMON_NO_DISCARD inline BrightnessAnalysisAlgorithm ToBrightnessAnalysisAlgorithm(
133{
135 {
137 }
139 {
141 }
142
143 throw peak::common::InternalErrorException("The given brightness algorithm is unknown!");
144}
145} // namespace detail
146
175class BrightnessAlgorithm : public IFeature<BrightnessAnalysisAlgorithm>
176{
177public:
190 explicit BrightnessAlgorithm(std::shared_ptr<peak::afl::Controller> controller)
191 : m_controller{ std::move(controller) }
192 {}
193
213 void Set(const BrightnessAnalysisAlgorithm& value) override
214 {
215 m_controller->SetBrightnessAlgorithm(detail::ToCType(value));
216 }
217
235 {
236 return detail::ToBrightnessAnalysisAlgorithm(m_controller->GetBrightnessAlgorithm());
237 }
238
254 {
255 archive.SetString("BrightnessAlgorithm", ToString(Get()));
256 }
257
274 {
275 Set(detail::ToBrightnessAnalysisAlgorithm(archive.GetString("BrightnessAlgorithm")));
276 }
277
278private:
286 std::shared_ptr<peak::afl::Controller> m_controller;
287};
288
289} // namespace features
290} // namespace autofeature
291} // namespace modules
292} // namespace pipeline
293} // namespace peak
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:50
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:59
virtual PEAK_COMMON_NO_DISCARD 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:213
BrightnessAlgorithm(std::shared_ptr< peak::afl::Controller > controller)
Constructs a BrightnessAlgorithm feature with the specified controller.
Definition peak_afl_brightness_algorithm.hpp:190
PEAK_COMMON_NO_DISCARD BrightnessAnalysisAlgorithm Get() const override
Gets the current brightness analysis algorithm.
Definition peak_afl_brightness_algorithm.hpp:234
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current brightness algorithm to an archive.
Definition peak_afl_brightness_algorithm.hpp:253
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes the brightness algorithm from an archive.
Definition peak_afl_brightness_algorithm.hpp:273
Base interface for auto feature implementations.
Definition peak_afl_ifeature.hpp:61
PEAK_COMMON_NO_DISCARD std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:79
BrightnessAnalysisAlgorithm
Brightness analysis algorithm enumeration.
Definition peak_afl_brightness_algorithm.hpp:41
@ Mean
Mean-based brightness calculation - uses the average value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:45
@ Median
Median-based brightness calculation - uses the median value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:43
peak_afl_controller_brightness_algorithm
Brightness calculation algorithms.
Definition peak_afl.h:505
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_ALGORITHM_MEAN
Mean-based brightness calculation.
Definition peak_afl.h:526
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_ALGORITHM_MEDIAN
Median-based brightness calculation.
Definition peak_afl.h:515
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
Definition peak_common_defines.hpp:91
Interface definitions and implementations for individual module types used within a pipeline.
Definition peak_afl_generic_auto_brightness.hpp:39
Interfaces and implementations for defining and controlling data processing pipelines.
Definition peak_afl_generic_auto_brightness.hpp:37