124inline std::ostream& operator<<(std::ostream& os,
Weight weight)
133PEAK_COMMON_NO_DISCARD
inline Weight ToWeight(
const std::string& name)
139 if (name ==
"Medium")
143 if (name ==
"Strong")
180PEAK_COMMON_NO_DISCARD
inline peak_afl_weighted_rectangle ToCType(WeightedROI roi)
182 peak_afl_weighted_rectangle result;
183 result.
roi.
x =
static_cast<uint32_t
>(roi.rect.GetX());
184 result.
roi.
y =
static_cast<uint32_t
>(roi.rect.GetY());
185 result.
roi.
width = roi.rect.GetWidth();
186 result.
roi.
height = roi.rect.GetHeight();
187 result.
weight = ToCType(roi.weight);
191PEAK_COMMON_NO_DISCARD
inline WeightedROI ToWeightedROI(peak_afl_weighted_rectangle roi)
195 const auto weight = ToWeight(roi.
weight);
196 return { rect, weight };
247 explicit WeightedRois(std::shared_ptr<peak::afl::Controller> controller)
248 : m_controller{ std::move(controller) }
270 m_controller->SetWeightedROI(detail::ToCType(value));
291 void Set(
const std::vector<WeightedROI>& value)
override
293 std::vector<peak_afl_weighted_rectangle> cRois;
294 cRois.reserve(value.size());
295 std::transform(value.cbegin(), value.cend(), std::back_inserter(cRois), [](
const auto& roi) { return detail::ToCType(roi); });
296 m_controller->SetWeightedROIs(cRois);
329 PEAK_COMMON_NO_DISCARD std::vector<WeightedROI>
Get()
const override
331 const auto cRois = m_controller->GetWeightedROIs();
333 std::vector<WeightedROI> rois;
334 rois.reserve(cRois.size());
336 cRois.cbegin(), cRois.cend(), std::back_inserter(rois), [](
const auto& cRoi) { return detail::ToWeightedROI(cRoi); });
357 std::vector<std::shared_ptr<peak::common::serialization::IArchive>> archives;
358 const auto weightedRois =
Get();
359 for (
const auto& roi : weightedRois)
362 subArchives->SetInt(
"X", roi.rect.GetX());
363 subArchives->SetInt(
"Y", roi.rect.GetY());
364 subArchives->SetInt(
"Width", roi.rect.GetWidth());
365 subArchives->SetInt(
"Height", roi.rect.GetHeight());
366 subArchives->SetString(
"Weight",
ToString(roi.weight));
368 archives.push_back(subArchives);
392 std::vector<WeightedROI> rois;
394 for (
const auto& subArchive : archives)
397 roi.
roi.
x =
static_cast<uint32_t
>(subArchive->GetInt(
"X"));
398 roi.
roi.
y =
static_cast<uint32_t
>(subArchive->GetInt(
"Y"));
399 roi.
roi.
width =
static_cast<uint32_t
>(subArchive->GetInt(
"Width"));
400 roi.
roi.
height =
static_cast<uint32_t
>(subArchive->GetInt(
"Height"));
401 roi.
weight = detail::ToCType(detail::ToWeight(subArchive->GetString(
"Weight")));
402 rois.emplace_back(detail::ToWeightedROI(roi));
416 std::shared_ptr<peak::afl::Controller> m_controller;
The exception thrown for signaling an unspecified error.
Definition peak_afl.hpp:385
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:54
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:55
void Set(const std::vector< WeightedROI > &value) override
Sets multiple weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:291
std::vector< WeightedROI > Get() const override
Gets the current weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:329
WeightedRois(std::shared_ptr< peak::afl::Controller > controller)
Constructs a WeightedRois feature with the specified controller.
Definition peak_afl_weighted_rois.hpp:247
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current weighted ROIs to an archive.
Definition peak_afl_weighted_rois.hpp:355
void Set(const WeightedROI &value)
Sets a single weighted region of interest.
Definition peak_afl_weighted_rois.hpp:268
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes weighted ROIs from an archive.
Definition peak_afl_weighted_rois.hpp:390
void SetPreset(RoiPreset preset)
Sets a predefined region of interest (ROI)
Definition peak_afl_weighted_rois.hpp:309
peak_afl_roi_preset
Predefined ROI preset configurations.
Definition peak_afl.h:1407
@ PEAK_AFL_CONTROLLER_ROI_PRESET_CENTER
Center region preset.
Definition peak_afl.h:1417
@ PEAK_AFL_STATUS_ERROR
General error occurred.
Definition peak_afl.h:396
peak_afl_roi_weight
ROI weight values for focus control.
Definition peak_afl.h:1035
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_WEAK
Low importance weight.
Definition peak_afl.h:1042
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_STRONG
High importance weight.
Definition peak_afl.h:1058
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_MEDIUM
Medium importance weight.
Definition peak_afl.h:1050
std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:74
RoiPreset
Preset enumeration for the Region of interest.
Definition peak_afl_weighted_rois.hpp:55
Weight
Weight enumeration for weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:36
@ Center
Sets a centered ROI that is one-third of the image dimensions.
Definition peak_afl_weighted_rois.hpp:57
@ Weak
Low importance - minimal influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:38
@ Medium
Normal importance - standard influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:40
@ Strong
High importance - strong influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:42
detail::RectangleT< int32_t, uint32_t > Rectangle
Rectangle with integer coordinates and unsigned dimensions.
Definition peak_common_rectangle.hpp:231
Interface definitions and implementations for individual module types used within a pipeline.
Definition peak_afl_generic_auto_brightness.hpp:35
Interfaces and implementations for defining and controlling data processing pipelines.
Definition peak_afl_generic_auto_brightness.hpp:33
Weighted region of interest structure.
Definition peak_afl_weighted_rois.hpp:71
peak::common::Rectangle rect
The rectangular region of interest.
Definition peak_afl_weighted_rois.hpp:73
Weight weight
The importance weight for this region.
Definition peak_afl_weighted_rois.hpp:76
uint32_t width
Width of rectangle in pixels.
Definition peak_afl.h:1514
uint32_t height
Height of rectangle in pixels.
Definition peak_afl.h:1521
uint32_t y
Y-coordinate of top-left corner.
Definition peak_afl.h:1507
uint32_t x
X-coordinate of top-left corner.
Definition peak_afl.h:1500
Weighted region of interest for focus control.
Definition peak_afl.h:1536
peak_afl_roi_weight weight
Weight of this region.
Definition peak_afl.h:1551
peak_afl_rectangle roi
Rectangular region definition.
Definition peak_afl.h:1543