23#include <peak/generic/peak_t_callback_manager.hpp>
44inline std::unique_ptr<features::BrightnessLimit> CreateBrightnessLimit(
50 return std::make_unique<features::BrightnessExposureLimit>(std::move(controller));
52 return std::make_unique<features::BrightnessGainLimit>(std::move(controller));
54 return std::make_unique<features::BrightnessGainAnalogLimit>(std::move(controller));
56 return std::make_unique<features::BrightnessGainDigitalLimit>(std::move(controller));
58 return std::make_unique<features::BrightnessGainCombinedLimit>(std::move(controller));
60 return std::make_unique<features::BrightnessGainHostLimit>(std::move(controller));
66class GenericAutoBrightness :
public IController
68 using ProcessingCallback = std::function<void()>;
71 friend BrightnessComponent;
73 explicit GenericAutoBrightness(
74 peak::afl::Manager& manager, ProcessingCallback callback,
const std::vector<BrightnessComponentType>& componentTypes)
75 : IController(manager)
77 , m_processingCallback{ std::move(callback) }
78 , m_skipFrames{ std::make_unique<features::SkipFrames>(m_controller) }
79 , m_autoTarget{ std::make_unique<features::AutoTarget>(m_controller) }
80 , m_autoTolerance{ std::make_unique<features::AutoTolerance>(m_controller) }
81 , m_autoPercentile{ std::make_unique<features::AutoPercentile>(m_controller) }
82 , m_roi{ std::make_unique<features::Roi>(m_controller) }
83 , m_brightnessAlgorithm{ std::make_unique<features::BrightnessAlgorithm>(m_controller) }
87 m_brightnessComponents.reserve(componentTypes.size());
88 for (
const auto& componentType : componentTypes)
95 m_brightnessComponents.emplace_back(std::unique_ptr<BrightnessComponent>(
96 new BrightnessComponent(m_controller, componentType, detail::CreateBrightnessLimit(m_controller, componentType))));
108 if (m_processingCallback)
110 m_processingCallback();
117 return "GenericAutoBrightness";
122 for (
const auto& feature : std::initializer_list<ISerializable*>{ m_skipFrames.get(), m_autoTarget.get(), m_autoTolerance.get(),
123 m_autoPercentile.get(), m_roi.get(), m_brightnessAlgorithm.get() })
125 feature->Serialize(archive);
128 for (
const auto& component : m_brightnessComponents)
131 component->Serialize(*componentArchive);
139 for (
const auto& feature : std::initializer_list<ISerializable*>{ m_skipFrames.get(), m_autoTarget.get(), m_autoTolerance.get(),
140 m_autoPercentile.get(), m_roi.get(), m_brightnessAlgorithm.get() })
142 feature->Deserialize(archive);
145 for (
const auto& component : m_brightnessComponents)
148 component->Deserialize(*componentArchive);
159 for (
const auto& component : m_brightnessComponents)
161 component->SetMode(mode);
168 for (
const auto& component : m_brightnessComponents)
172 return controllerMode;
175 controllerMode = (std::max)(controllerMode, component->GetMode());
178 return controllerMode;
188 return *m_skipFrames;
193 return *m_autoTarget;
198 return *m_autoTolerance;
203 return *m_autoPercentile;
213 return *m_brightnessAlgorithm;
219 if (
nullptr == component)
236 if (
nullptr == component)
253 if (
nullptr == component)
270 if (
nullptr == component)
287 if (
nullptr == component)
290 "Host gain component is not available! Call IAutofeature::SetGainModule to set gain module!",
304 std::vector<BrightnessComponent*> components;
305 std::transform(m_brightnessComponents.begin(), m_brightnessComponents.end(), std::back_inserter(components),
306 [](
const auto& elem) { return elem.get(); });
312 auto entry = std::find_if(m_brightnessComponents.begin(), m_brightnessComponents.end(),
313 [componentType](
const std::unique_ptr<BrightnessComponent>& component) { return component->GetType() == componentType; });
314 if (entry != m_brightnessComponents.end())
325 AutoPercentile().
Set(13);
326 AutoTarget().
Set(150);
327 AutoTolerance().
Set(3);
331 for (
auto* component : GetComponents())
333 component->SetLimit({ 0, (std::numeric_limits<double>::max)() });
339 return m_FinishedCallbackManager.RegisterCallback(callback);
344 m_FinishedCallbackManager.UnregisterCallback(callbackHandle);
348 peak::core::TTriggerCallbackManager<IController::FinishedCallbackHandle, IController::FinishedCallback>
349 m_FinishedCallbackManager;
351 std::shared_ptr<peak::afl::Controller> m_controller{};
352 std::vector<std::unique_ptr<BrightnessComponent>> m_brightnessComponents{};
353 ProcessingCallback m_processingCallback{};
355 std::unique_ptr<features::SkipFrames> m_skipFrames{};
356 std::unique_ptr<features::AutoTarget> m_autoTarget{};
357 std::unique_ptr<features::AutoTolerance> m_autoTolerance{};
358 std::unique_ptr<features::AutoPercentile> m_autoPercentile{};
359 std::unique_ptr<features::Roi> m_roi{};
360 std::unique_ptr<features::BrightnessAlgorithm> m_brightnessAlgorithm{};
static std::shared_ptr< Controller > Create(peak_afl_controllerType type)
Create a new controller.
Definition peak_afl.hpp:2420
void RegisterFinishedCallback(const callback::FinishedCallback &callback)
Set finished callback for a controller.
Definition peak_afl.hpp:2887
void RegisterProcessingCallback(const callback::ProcessingCallback &callback)
Set the data callback for a controller.
Definition peak_afl.hpp:3011
bool IsBrightnessComponentUnitSupported(peak_afl_controller_brightness_component component) const
Check if a specific unit is supported for a brightness controller component.
Definition peak_afl.hpp:3213
Central coordination object for automatic camera feature control.
Definition peak_afl.hpp:663
void AddController(const std::shared_ptr< Controller > &controller)
Add a controller to an automanager.
Definition peak_afl.hpp:2245
The exception thrown for passing an invalid parameter to a function.
Definition peak_afl.hpp:391
The exception thrown when a functionality is not supported.
Definition peak_afl.hpp:416
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:59
virtual std::shared_ptr< IArchive > GetArchive(const std::string &key) const =0
Retrieves a nested archive by key.
virtual std::shared_ptr< IArchive > CreateArchive() const =0
Creates a new, empty archive instance.
virtual void SetArchive(const std::string &key, const std::shared_ptr< IArchive > &value)=0
Stores a nested archive object.
std::function< void()> FinishedCallback
Callback function type for operation completion notifications.
Definition peak_afl_icontroller.hpp:233
virtual std::string GetName() const =0
Gets the unique name of this controller.
peak::afl::Manager & GetManager()
Gets a reference to the API manager.
Definition peak_afl_icontroller.hpp:368
virtual bool IsRunning() const =0
Checks if the controller is currently running.
FinishedCallback * FinishedCallbackHandle
Handle type for managing callback registrations.
Definition peak_afl_icontroller.hpp:238
virtual ControllerType GetType() const =0
Gets the type of this controller.
virtual ControllerMode GetMode() const =0
Gets the current operational mode of this controller.
virtual void ResetToDefault()=0
Resets the controller to its default configuration.
void Set(const double &value) override
Sets the auto percentile value.
Definition peak_afl_auto_percentile.hpp:95
void Set(const uint32_t &value) override
Sets the auto target brightness value.
Definition peak_afl_auto_target.hpp:98
void Set(const uint32_t &value) override
Sets the auto tolerance value.
Definition peak_afl_auto_tolerance.hpp:101
void Set(const BrightnessAnalysisAlgorithm &value) override
Sets the brightness analysis algorithm.
Definition peak_afl_brightness_algorithm.hpp:212
void Set(const peak::common::Rectangle &value) override
Sets the region of interest rectangle.
Definition peak_afl_roi.hpp:98
void Set(const uint32_t &value) override
Sets the number of frames to skip.
Definition peak_afl_skip_frames.hpp:96
@ PEAK_AFL_CONTROLLER_TYPE_BRIGHTNESS
Automatic brightness exposure/gain controller.
Definition peak_afl.h:507
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_HOST_GAIN
Host-based software gain.
Definition peak_afl.h:955
@ PEAK_AFL_STATUS_NOT_SUPPORTED
Feature or operation not supported.
Definition peak_afl.h:465
@ PEAK_AFL_STATUS_INVALID_PARAMETER
Invalid parameter provided.
Definition peak_afl.h:419
ControllerMode
Controller operation mode enumeration.
Definition peak_afl_icontroller.hpp:59
ControllerType
Controller type enumeration.
Definition peak_afl_icontroller.hpp:40
std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:78
@ Continuous
Continuous operation - automatic processing on every frame.
Definition peak_afl_icontroller.hpp:63
@ Off
Controller is disabled - no automatic processing.
Definition peak_afl_icontroller.hpp:61
@ Brightness
Automatic brightness controller - manages exposure and gain.
Definition peak_afl_icontroller.hpp:44
BrightnessComponentType
Brightness component type enumeration.
Definition peak_afl_brightness_component.hpp:38
@ Median
Median-based brightness calculation - uses the median value of pixel intensities.
Definition peak_afl_brightness_algorithm.hpp:42
@ CombinedGain
Combined gain component - both analog and digital (combined) gain.
Definition peak_afl_brightness_component.hpp:48
@ Gain
Automatic gain component - automatic gain control.
Definition peak_afl_brightness_component.hpp:52
@ AnalogGain
Analog gain component - hardware gain applied before digitization.
Definition peak_afl_brightness_component.hpp:44
@ DigitalGain
Digital gain component - gain applied after digitization.
Definition peak_afl_brightness_component.hpp:46
@ HostGain
Host gain component - software-based gain processing.
Definition peak_afl_brightness_component.hpp:50
@ Exposure
Exposure time component - controls sensor integration time.
Definition peak_afl_brightness_component.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
Brightness controller process data.
Definition peak_afl.h:1175
Generic process data structure.
Definition peak_afl.h:1129