IDS peak AFL v2.1.0
Loading...
Searching...
No Matches
peak_afl_roi.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
11
14
15#include <memory>
16
17namespace peak
18{
19namespace pipeline
20{
21namespace modules
22{
23namespace autofeature
24{
25namespace features
26{
56class Roi : public IFeature<peak::common::Rectangle>
57{
58public:
71 explicit Roi(std::shared_ptr<peak::afl::Controller> controller)
72 : m_controller{ std::move(controller) }
73 {}
74
94 void Set(const peak::common::Rectangle& value) override
95 {
96 if (value.GetX() < 0 || value.GetY() < 0)
97 {
99 "Negative x or y is not supported!", PEAK_AFL_STATUS_INVALID_PARAMETER);
100 }
101
102 m_controller->SetROI(
103 { static_cast<uint32_t>(value.GetX()), static_cast<uint32_t>(value.GetY()), value.GetWidth(), value.GetHeight() });
104 }
105
122 PEAK_COMMON_NO_DISCARD peak::common::Rectangle Get() const override
123 {
124 const auto result = m_controller->GetROI();
125 return { static_cast<int32_t>(result.x), static_cast<int32_t>(result.y), result.width, result.height };
126 }
127
144 {
145 auto subArchive = archive.CreateArchive();
146
147 const auto roi = Get();
148 subArchive->SetInt("X", roi.GetX());
149 subArchive->SetInt("Y", roi.GetY());
150 subArchive->SetInt("Width", roi.GetWidth());
151 subArchive->SetInt("Height", roi.GetHeight());
152
153 archive.SetArchive("Roi", subArchive);
154 }
155
173 {
174 const auto subArchive = archive.GetArchive("Roi");
175
176 const auto x = static_cast<int32_t>(subArchive->GetInt("X"));
177 const auto y = static_cast<int32_t>(subArchive->GetInt("Y"));
178 const auto width = static_cast<uint32_t>(subArchive->GetInt("Width"));
179 const auto height = static_cast<uint32_t>(subArchive->GetInt("Height"));
180
181 Set({ x, y, width, height });
182 }
183
184private:
192 std::shared_ptr<peak::afl::Controller> m_controller;
193};
194} // namespace features
195} // namespace autofeature
196} // namespace modules
197} // namespace pipeline
198} // namespace peak
The exception thrown for passing an invalid parameter to a function.
Definition peak_afl.hpp:436
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:54
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.
Base interface for auto feature implementations.
Definition peak_afl_ifeature.hpp:55
peak::common::Rectangle Get() const override
Gets the current region of interest rectangle.
Definition peak_afl_roi.hpp:122
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the current ROI to an archive.
Definition peak_afl_roi.hpp:143
Roi(std::shared_ptr< peak::afl::Controller > controller)
Constructs a Roi feature with the specified controller.
Definition peak_afl_roi.hpp:71
void Deserialize(const peak::common::serialization::IArchive &archive) override
Deserializes the ROI from an archive.
Definition peak_afl_roi.hpp:172
void Set(const peak::common::Rectangle &value) override
Sets the region of interest rectangle.
Definition peak_afl_roi.hpp:94
@ PEAK_AFL_STATUS_INVALID_PARAMETER
Invalid parameter provided.
Definition peak_afl.h:416
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