23#include <peak/generic/peak_t_callback_manager.hpp>
40 explicit GenericAutoFocus(peak::afl::Manager& manager)
41 : IController(manager)
43 , m_skipFrames{ std::make_unique<features::SkipFrames>(m_controller) }
44 , m_hysteresis{ std::make_unique<features::Hysteresis>(m_controller) }
45 , m_weightedRois{ std::make_unique<features::WeightedRois>(m_controller) }
46 , m_sharpnessAlgorithm{ std::make_unique<features::SharpnessAlgorithm>(m_controller) }
47 , m_searchAlgorithm{ std::make_unique<features::SearchAlgorithm>(m_controller) }
48 , m_focusLimit{ std::make_unique<features::FocusLimit>(m_controller) }
52 m_controller->RegisterFinishedCallback([
this]() { m_FinishedCallbackManager.TriggerCallbacks(); });
57 return "GenericAutoFocus";
60 void Serialize(peak::common::serialization::IArchive& archive)
const override
62 for (
const auto& feature : std::initializer_list<const peak::common::serialization::ISerializable*>{ m_skipFrames.get(),
63 m_hysteresis.get(), m_weightedRois.get(), m_sharpnessAlgorithm.get(), m_searchAlgorithm.get(), m_focusLimit.get() })
65 feature->Serialize(archive);
71 void Deserialize(
const peak::common::serialization::IArchive& archive)
override
73 for (
const auto& feature : std::initializer_list<peak::common::serialization::ISerializable*>{ m_skipFrames.get(),
74 m_hysteresis.get(), m_weightedRois.get(), m_sharpnessAlgorithm.get(), m_searchAlgorithm.get(), m_focusLimit.get() })
76 feature->Deserialize(archive);
79 SetMode(detail::ToControllerMode(archive.
GetString(
"Mode")));
84 m_controller->SetMode(ToCType(mode));
89 return ToControllerMode(m_controller->GetMode());
104 const auto focusLimit = m_controller->GetDefaultLimit();
105 FocusLimit().Set({ focusLimit.min, focusLimit.max });
113 return *m_skipFrames;
118 return *m_hysteresis;
123 return *m_weightedRois;
128 return *m_sharpnessAlgorithm;
133 return *m_searchAlgorithm;
138 return *m_focusLimit;
148 return m_FinishedCallbackManager.RegisterCallback(callback);
153 m_FinishedCallbackManager.UnregisterCallback(callbackHandle);
157 std::shared_ptr<peak::afl::Controller> m_controller;
158 peak::core::TTriggerCallbackManager<IController::FinishedCallbackHandle, IController::FinishedCallback>
159 m_FinishedCallbackManager;
160 std::unique_ptr<features::SkipFrames> m_skipFrames{};
161 std::unique_ptr<features::Hysteresis> m_hysteresis{};
162 std::unique_ptr<features::WeightedRois> m_weightedRois{};
163 std::unique_ptr<features::SharpnessAlgorithm> m_sharpnessAlgorithm{};
164 std::unique_ptr<features::SearchAlgorithm> m_searchAlgorithm{};
165 std::unique_ptr<features::FocusLimit> m_focusLimit{};
void AddController(const std::shared_ptr< Controller > &controller)
Add a controller to an automanager.
Definition peak_afl.hpp:2252
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.
Abstract base interface for all automatic controllers.
Definition peak_afl_icontroller.hpp:227
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.
@ PEAK_AFL_CONTROLLER_TYPE_AUTOFOCUS
Automatic focus controller.
Definition peak_afl.h:529
@ PEAK_AFL_CONTROLLER_ROI_PRESET_CENTER
Center region preset.
Definition peak_afl.h:1420
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
@ Off
Controller is disabled - no automatic processing.
Definition peak_afl_icontroller.hpp:61
@ Focus
Automatic focus controller - manages lens focus positioning.
Definition peak_afl_icontroller.hpp:42
@ Tenengrad
Tenengrad algorithm - gradient-based sharpness measurement.
Definition peak_afl_sharpness_algorithm.hpp:48
@ GoldenRatio
Golden ratio search - efficient for unimodal focus curves.
Definition peak_afl_search_algorithm.hpp:49
#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