IDS peak AFL v2.0.1
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{
46
60{
61 if (algorithm == BrightnessAnalysisAlgorithm::Mean)
62 {
63 return "Mean";
64 }
66 {
67 return "Median";
68 }
69
71 "The given brightness algorithm is unknown!", PEAK_AFL_STATUS_INVALID_PARAMETER);
72}
73
92inline std::ostream& operator<<(std::ostream& os, BrightnessAnalysisAlgorithm algorithm)
93{
94 return os << ToString(algorithm);
95}
96
97namespace features
98{
99namespace detail
100{
101PEAK_COMMON_NO_DISCARD inline BrightnessAnalysisAlgorithm ToBrightnessAnalysisAlgorithm(const std::string& algorithm)
102{
103 if (algorithm == "Median")
104 {
106 }
107 if (algorithm == "Mean")
108 {
110 }
111
113 "The given brightness algorithm " + algorithm + " is unknown!", PEAK_AFL_STATUS_INVALID_PARAMETER);
114}
115
117{
119 {
121 }
122 if (algorithm == BrightnessAnalysisAlgorithm::Mean)
123 {
125 }
126
127 throw peak::afl::error::InternalErrorException("The given brightness algorithm is unknown!", PEAK_AFL_STATUS_ERROR);
128}
129
130PEAK_COMMON_NO_DISCARD inline BrightnessAnalysisAlgorithm ToBrightnessAnalysisAlgorithm(
132{
134 {
136 }
138 {
140 }
141
142 throw peak::afl::error::InternalErrorException("The given brightness algorithm is unknown!", PEAK_AFL_STATUS_ERROR);
143}
144} // namespace detail
145
174class BrightnessAlgorithm : public IFeature<BrightnessAnalysisAlgorithm>
175{
176public:
189 explicit BrightnessAlgorithm(std::shared_ptr<peak::afl::Controller> controller)
190 : m_controller{ std::move(controller) }
191 {}
192
212 void Set(const BrightnessAnalysisAlgorithm& value) override
213 {
214 m_controller->SetBrightnessAlgorithm(detail::ToCType(value));
215 }
216
234 {
235 return detail::ToBrightnessAnalysisAlgorithm(m_controller->GetBrightnessAlgorithm());
236 }
237
253 {
254 archive.SetString("BrightnessAlgorithm", ToString(Get()));
255 }
256
273 {
274 Set(detail::ToBrightnessAnalysisAlgorithm(archive.GetString("BrightnessAlgorithm")));
275 }
276
277private:
285 std::shared_ptr<peak::afl::Controller> m_controller;
286};
287} // namespace features
288} // namespace autofeature
289} // namespace modules
290} // namespace pipeline
291} // namespace peak
The exception thrown for passing an invalid parameter to a function.
Definition peak_afl.hpp:391
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:59
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:212
BrightnessAlgorithm(std::shared_ptr< peak::afl::Controller > controller)
Constructs a BrightnessAlgorithm feature with the specified controller.
Definition peak_afl_brightness_algorithm.hpp:189
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current brightness algorithm to an archive.
Definition peak_afl_brightness_algorithm.hpp:252
BrightnessAnalysisAlgorithm Get() const override
Gets the current brightness analysis algorithm.
Definition peak_afl_brightness_algorithm.hpp:233
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes the brightness algorithm from an archive.
Definition peak_afl_brightness_algorithm.hpp:272
Base interface for auto feature implementations.
Definition peak_afl_ifeature.hpp:59
peak_afl_controller_brightness_algorithm
Brightness calculation algorithms.
Definition peak_afl.h:772
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_ALGORITHM_MEAN
Mean-based brightness calculation.
Definition peak_afl.h:793
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_ALGORITHM_MEDIAN
Median-based brightness calculation.
Definition peak_afl.h:782
@ PEAK_AFL_STATUS_INVALID_PARAMETER
Invalid parameter provided.
Definition peak_afl.h:419
@ PEAK_AFL_STATUS_ERROR
General error occurred.
Definition peak_afl.h:399
std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:78
BrightnessAnalysisAlgorithm
Brightness analysis algorithm enumeration.
Definition peak_afl_brightness_algorithm.hpp:40
@ Mean
Mean-based brightness calculation - uses the average value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:44
@ Median
Median-based brightness calculation - uses the median value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:42
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
Definition peak_common_defines.h:86
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