IDS peak ICV v1.2.0
Loading...
Searching...
No Matches
peak_icv_color_correction_matrix.hpp
Go to the documentation of this file.
1
11#pragma once
12
16
17namespace peak
18{
19namespace pipeline
20{
21
43 : public peak::icv::Matrix<float, 3, 3>
45{
46public:
47 using peak::icv::Matrix<float, 3, 3>::Matrix;
48
55
63 explicit ColorCorrectionMatrix(const float (&data)[3][3]) // NOLINT
64 : Matrix(data)
65 {}
66
74 ColorCorrectionMatrix(Matrix<float, 3, 3> matrix) // NOLINT
75 : Matrix(std::move(matrix))
76 {}
77
86 ColorCorrectionMatrix(std::string name, const float (&data)[3][3]) // NOLINT
87 : Matrix(data)
88 , m_name{ std::move(name) }
89 {}
90
99 ColorCorrectionMatrix(std::string name, Matrix<float, 3, 3> matrix) // NOLINT
100 : Matrix(std::move(matrix))
101 , m_name{ std::move(name) }
102 {}
103
115 void Serialize(peak::common::serialization::IArchive& archive) const override;
116
117
128 void Deserialize(const peak::common::serialization::IArchive& archive) override;
129
130 bool operator==(const ColorCorrectionMatrix& other) const;
131
132private:
133 std::string m_name;
134};
135
137{
138 std::vector<double> doubleValues(9);
139 std::transform(cbegin(), cend(), doubleValues.begin(), [&](const float v) {
140 return static_cast<double>(v);
141 });
142 archive.SetDoubleArray(m_name, doubleValues);
143}
144
146{
147 const auto doubleValues = archive.GetDoubleArray(m_name);
148 std::transform(doubleValues.cbegin(), doubleValues.cend(), begin(), [&](const double v) {
149 return static_cast<float>(v);
150 });
151}
152
154{
155 return std::equal(cbegin(), cend(), other.cbegin(), [](float a, float b) {
156 return peak::common::detail::AreAlmostEqual(a, b, 6);
157 });
158}
159
167PEAK_COMMON_NO_DISCARD inline std::string ToString(const ColorCorrectionMatrix& matrix)
168{
169 std::stringstream ss;
170 ss << matrix;
171 return ss.str();
172}
173
174} // namespace pipeline
175} // namespace peak
Interface for a hierarchical key-value archive system.
virtual std::vector< double > GetDoubleArray(const std::string &key) const =0
Retrieves an array of doubles by key.
virtual void SetDoubleArray(const std::string &key, const std::vector< double > &value)=0
Stores an array of doubles.
Interface for objects that can be serialized to and deserialized from an archive.
A class template for a two-dimensional matrix.
ColorCorrectionMatrix(const float(&data)[3][3])
Creates an instance of class ColorCorrectionMatrix with data.
bool operator==(const ColorCorrectionMatrix &other) const
ColorCorrectionMatrix(std::string name, const float(&data)[3][3])
Creates an instance of class ColorCorrectionMatrix.
ColorCorrectionMatrix()=default
Creates an instance of class ColorCorrectionMatrix.
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the object's internal state into the provided archive.
void Deserialize(const peak::common::serialization::IArchive &archive) override
Restores the object's state from the provided archive.
ColorCorrectionMatrix(std::string name, Matrix< float, 3, 3 > matrix)
Creates an instance of class ColorCorrectionMatrix.
ColorCorrectionMatrix(Matrix< float, 3, 3 > matrix)
Creates an instance of class ColorCorrectionMatrix with data.
std::string ToString(BinningMode mode)
Converts a BinningMode enum value to its string representation.