114inline std::ostream& operator<<(std::ostream& os,
Weight weight)
131 if (name ==
"Medium")
135 if (name ==
"Strong")
154 throw peak::common::InternalErrorException(
"Invalid weight!");
169 throw peak::common::InternalErrorException(
"Invalid weight!");
174 peak_afl_weighted_rectangle result;
175 result.
roi.
x = roi.rect.GetX();
176 result.
roi.
y = roi.rect.GetY();
177 result.
roi.
width = roi.rect.GetWidth();
178 result.
roi.
height = roi.rect.GetHeight();
179 result.
weight = ToCType(roi.weight);
187 const auto weight = ToWeight(roi.
weight);
188 return { rect, weight };
239 explicit WeightedRois(std::shared_ptr<peak::afl::Controller> controller)
240 : m_controller{ std::move(controller) }
262 m_controller->SetWeightedROI(detail::ToCType(value));
283 void Set(
const std::vector<WeightedROI>& value)
override
285 std::vector<peak_afl_weighted_rectangle> cRois;
286 cRois.reserve(value.size());
287 std::transform(value.cbegin(), value.cend(), std::back_inserter(cRois), [](
const auto& roi) { return detail::ToCType(roi); });
288 m_controller->SetWeightedROIs(cRois);
308 const auto cRois = m_controller->GetWeightedROIs();
310 std::vector<WeightedROI> rois;
311 rois.reserve(cRois.size());
313 cRois.cbegin(), cRois.cend(), std::back_inserter(rois), [](
const auto& cRoi) { return detail::ToWeightedROI(cRoi); });
334 std::vector<std::shared_ptr<peak::common::serialization::IArchive>> archives;
335 const auto weightedRois =
Get();
336 for (
const auto& roi : weightedRois)
339 subArchives->SetInt(
"X", roi.rect.GetX());
340 subArchives->SetInt(
"Y", roi.rect.GetY());
341 subArchives->SetInt(
"Width", roi.rect.GetWidth());
342 subArchives->SetInt(
"Height", roi.rect.GetHeight());
343 subArchives->SetString(
"Weight",
ToString(roi.weight));
345 archives.push_back(subArchives);
369 std::vector<WeightedROI> rois;
371 for (
const auto& subArchive : archives)
374 roi.
roi.
x =
static_cast<uint32_t
>(subArchive->GetInt(
"X"));
375 roi.
roi.
y =
static_cast<uint32_t
>(subArchive->GetInt(
"Y"));
376 roi.
roi.
width =
static_cast<uint32_t
>(subArchive->GetInt(
"Width"));
377 roi.
roi.
height =
static_cast<uint32_t
>(subArchive->GetInt(
"Height"));
378 roi.
weight = detail::ToCType(detail::ToWeight(subArchive->GetString(
"Weight")));
379 rois.emplace_back(detail::ToWeightedROI(roi));
393 std::shared_ptr<peak::afl::Controller> m_controller;
Thrown when an unexpected internal error occurs.
Definition peak_common_exceptions.hpp:74
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:59
virtual void SetArchiveArray(const std::string &key, const std::vector< std::shared_ptr< IArchive > > &value)=0
Stores an array of nested archives.
virtual PEAK_COMMON_NO_DISCARD std::vector< std::shared_ptr< IArchive > > GetArchiveArray(const std::string &key) const =0
Retrieves an array of nested archives by key.
virtual PEAK_COMMON_NO_DISCARD std::shared_ptr< IArchive > CreateArchive() const =0
Creates a new, empty archive instance.
Base interface for auto feature implementations.
Definition peak_afl_ifeature.hpp:61
void Set(const std::vector< WeightedROI > &value) override
Sets multiple weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:283
PEAK_COMMON_NO_DISCARD std::vector< WeightedROI > Get() const override
Gets the current weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:306
WeightedRois(std::shared_ptr< peak::afl::Controller > controller)
Constructs a WeightedRois feature with the specified controller.
Definition peak_afl_weighted_rois.hpp:239
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current weighted ROIs to an archive.
Definition peak_afl_weighted_rois.hpp:332
void Set(const WeightedROI &value)
Sets a single weighted region of interest.
Definition peak_afl_weighted_rois.hpp:260
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes weighted ROIs from an archive.
Definition peak_afl_weighted_rois.hpp:367
PEAK_COMMON_NO_DISCARD std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:79
Weight
Weight enumeration for weighted regions of interest.
Definition peak_afl_weighted_rois.hpp:41
@ Weak
Low importance - minimal influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:43
@ Medium
Normal importance - standard influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:45
@ Strong
High importance - strong influence on auto algorithms.
Definition peak_afl_weighted_rois.hpp:47
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
Definition peak_common_defines.hpp:91
detail::RectangleT< int32_t, uint32_t > Rectangle
Rectangle with integer coordinates and unsigned dimensions.
Definition peak_common_rectangle.hpp:235
peak_afl_roi_weight
ROI weight values for focus control.
Definition peak_afl.h:770
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_WEAK
Low importance weight.
Definition peak_afl.h:777
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_STRONG
High importance weight.
Definition peak_afl.h:793
@ PEAK_AFL_CONTROLLER_ROI_WEIGHT_MEDIUM
Medium importance weight.
Definition peak_afl.h:785
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:61
peak::common::Rectangle rect
The rectangular region of interest.
Definition peak_afl_weighted_rois.hpp:63
Weight weight
The importance weight for this region.
Definition peak_afl_weighted_rois.hpp:66
uint32_t width
Width of rectangle in pixels.
Definition peak_afl.h:1248
uint32_t height
Height of rectangle in pixels.
Definition peak_afl.h:1255
uint32_t y
Y-coordinate of top-left corner.
Definition peak_afl.h:1241
uint32_t x
X-coordinate of top-left corner.
Definition peak_afl.h:1234
Weighted region of interest for focus control.
Definition peak_afl.h:1270
peak_afl_roi_weight weight
Weight of this region.
Definition peak_afl.h:1285
peak_afl_rectangle roi
Rectangular region definition.
Definition peak_afl.h:1277