128inline std::ostream& operator<<(std::ostream& os,
Weight weight)
137PEAK_COMMON_NO_DISCARD
inline Weight ToWeight(
const std::string& name)
143 if (name ==
"Medium")
147 if (name ==
"Strong")
184PEAK_COMMON_NO_DISCARD
inline peak_afl_weighted_rectangle ToCType(WeightedROI roi)
186 peak_afl_weighted_rectangle result;
187 result.
roi.
x =
static_cast<uint32_t
>(roi.rect.GetX());
188 result.
roi.
y =
static_cast<uint32_t
>(roi.rect.GetY());
189 result.
roi.
width = roi.rect.GetWidth();
190 result.
roi.
height = roi.rect.GetHeight();
191 result.
weight = ToCType(roi.weight);
195PEAK_COMMON_NO_DISCARD
inline WeightedROI ToWeightedROI(peak_afl_weighted_rectangle roi)
199 const auto weight = ToWeight(roi.
weight);
200 return { rect, weight };
251 explicit WeightedRois(std::shared_ptr<peak::afl::Controller> controller)
252 : m_controller{ std::move(controller) }
274 m_controller->SetWeightedROI(detail::ToCType(value));
295 void Set(
const std::vector<WeightedROI>& value)
override
297 std::vector<peak_afl_weighted_rectangle> cRois;
298 cRois.reserve(value.size());
299 std::transform(value.cbegin(), value.cend(), std::back_inserter(cRois), [](
const auto& roi) { return detail::ToCType(roi); });
300 m_controller->SetWeightedROIs(cRois);
333 PEAK_COMMON_NO_DISCARD std::vector<WeightedROI>
Get()
const override
335 const auto cRois = m_controller->GetWeightedROIs();
337 std::vector<WeightedROI> rois;
338 rois.reserve(cRois.size());
340 cRois.cbegin(), cRois.cend(), std::back_inserter(rois), [](
const auto& cRoi) { return detail::ToWeightedROI(cRoi); });
361 std::vector<std::shared_ptr<peak::common::serialization::IArchive>> archives;
362 const auto weightedRois =
Get();
363 for (
const auto& roi : weightedRois)
366 subArchives->SetInt(
"X", roi.rect.GetX());
367 subArchives->SetInt(
"Y", roi.rect.GetY());
368 subArchives->SetInt(
"Width", roi.rect.GetWidth());
369 subArchives->SetInt(
"Height", roi.rect.GetHeight());
370 subArchives->SetString(
"Weight",
ToString(roi.weight));
372 archives.push_back(subArchives);
396 std::vector<WeightedROI> rois;
398 for (
const auto& subArchive : archives)
401 roi.
roi.
x =
static_cast<uint32_t
>(subArchive->GetInt(
"X"));
402 roi.
roi.
y =
static_cast<uint32_t
>(subArchive->GetInt(
"Y"));
403 roi.
roi.
width =
static_cast<uint32_t
>(subArchive->GetInt(
"Width"));
404 roi.
roi.
height =
static_cast<uint32_t
>(subArchive->GetInt(
"Height"));
405 roi.
weight = detail::ToCType(detail::ToWeight(subArchive->GetString(
"Weight")));
406 rois.emplace_back(detail::ToWeightedROI(roi));
420 std::shared_ptr<peak::afl::Controller> m_controller;
The exception thrown for signaling an unspecified error.
Definition peak_afl.hpp:340
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:59
virtual std::vector< std::shared_ptr< IArchive > > GetArchiveArray(const std::string &key) const =0
Retrieves an array of nested archives by key.
virtual void SetArchiveArray(const std::string &key, const std::vector< std::shared_ptr< IArchive > > &value)=0
Stores an array of nested archives.
virtual std::shared_ptr< IArchive > CreateArchive() const =0
Creates a new, empty archive instance.
Base interface for auto feature implementations.
Definition peak_afl_ifeature.hpp:59
void Set(const std::vector< WeightedROI > &value) override
Sets multiple weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:295
std::vector< WeightedROI > Get() const override
Gets the current weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:333
WeightedRois(std::shared_ptr< peak::afl::Controller > controller)
Constructs a WeightedRois feature with the specified controller.
Definition peak_afl_weighted_rois.hpp:251
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current weighted ROIs to an archive.
Definition peak_afl_weighted_rois.hpp:359
void Set(const WeightedROI &value)
Sets a single weighted region of interest.
Definition peak_afl_weighted_rois.hpp:272
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes weighted ROIs from an archive.
Definition peak_afl_weighted_rois.hpp:394
void SetPreset(RoiPreset preset)
Sets a predefined region of interest (ROI)
Definition peak_afl_weighted_rois.hpp:313
peak_afl_roi_preset
Predefined ROI preset configurations.
Definition peak_afl.h:1410
@ PEAK_AFL_CONTROLLER_ROI_PRESET_CENTER
Center region preset.
Definition peak_afl.h:1420
@ PEAK_AFL_STATUS_ERROR
General error occurred.
Definition peak_afl.h:399
peak_afl_roi_weight
ROI weight values for focus control.
Definition peak_afl.h:1038
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_WEAK
Low importance weight.
Definition peak_afl.h:1045
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_STRONG
High importance weight.
Definition peak_afl.h:1061
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_MEDIUM
Medium importance weight.
Definition peak_afl.h:1053
std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:78
RoiPreset
Preset enumeration for the Region of interest.
Definition peak_afl_weighted_rois.hpp:59
Weight
Weight enumeration for weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:40
@ Center
Sets a centered ROI that is one-third of the image dimensions.
Definition peak_afl_weighted_rois.hpp:61
@ Weak
Low importance - minimal influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:42
@ Medium
Normal importance - standard influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:44
@ Strong
High importance - strong influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:46
detail::RectangleT< int32_t, uint32_t > Rectangle
Rectangle with integer coordinates and unsigned dimensions.
Definition peak_common_rectangle.hpp:236
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
Weighted region of interest structure.
Definition peak_afl_weighted_rois.hpp:75
peak::common::Rectangle rect
The rectangular region of interest.
Definition peak_afl_weighted_rois.hpp:77
Weight weight
The importance weight for this region.
Definition peak_afl_weighted_rois.hpp:80
uint32_t width
Width of rectangle in pixels.
Definition peak_afl.h:1517
uint32_t height
Height of rectangle in pixels.
Definition peak_afl.h:1524
uint32_t y
Y-coordinate of top-left corner.
Definition peak_afl.h:1510
uint32_t x
X-coordinate of top-left corner.
Definition peak_afl.h:1503
Weighted region of interest for focus control.
Definition peak_afl.h:1539
peak_afl_roi_weight weight
Weight of this region.
Definition peak_afl.h:1554
peak_afl_rectangle roi
Rectangular region definition.
Definition peak_afl.h:1546