CVB++ 15.0
result.hpp
1#pragma once
2
3#include "../point_2d.hpp"
4
5#include "../size_2d.hpp"
6#include "../string.hpp"
7#include "../shims/stdoptional.hpp"
8
9#include "_decl/decl_config_base.hpp"
10
11namespace Cvb
12{
13
14 CVB_BEGIN_INLINE_NS
15
17
25 namespace CodeReader
26 {
27
28 enum class Symbology;
29
31 enum class DecodeStatus
32 {
34 Failure = -1,
36 Success = 100
37 };
38
40
43 enum class CompositeType
44 {
46 None = 0,
48 CCA = CExports::CVCRValueSymbology::CVCRVS_CCA,
50 CCB = CExports::CVCRValueSymbology::CVCRVS_CCB,
52 CCC = CExports::CVCRValueSymbology::CVCRVS_CCC
53 };
54
56
62 class Result2D
63 {
64 friend class ResultHandle;
65
66 private:
67 Result2D(int quality, int rows, int columns, const Size2D<double> &size, int errorCorrectionErasureCodewords,
68 int errorCorrectionCodewords, const CompositeType compositeType = CompositeType::None)
69 : quality_(quality)
70 , rows_(rows)
71 , columns_(columns)
72 , size_(size)
73 , errorCorrectionCodewords_(errorCorrectionCodewords)
74 , errorCorrectionErasureCodewords_(errorCorrectionErasureCodewords)
75 , compositeType_(compositeType)
76 {
77 }
78
79 public:
81
84 int Rows() const noexcept
85 {
86 return rows_;
87 }
88
90
93 int Columns() const noexcept
94 {
95 return columns_;
96 }
97
99
103 Size2D<double> Size() const noexcept
104 {
105 return size_;
106 }
107
109
115 int Quality() const noexcept
116 {
117 return quality_;
118 }
119
121
124 int ErrorCorrectionCodewords() const noexcept
125 {
126 return errorCorrectionCodewords_;
127 }
128
130
134 {
135 return errorCorrectionErasureCodewords_;
136 }
137
139
143 {
144 return compositeType_;
145 }
146
147 private:
148 int quality_ = 0; // 0-100
149 int errorCorrectionCodewords_ = 0;
150 int errorCorrectionErasureCodewords_ = 0;
151 int rows_ = 0;
152 int columns_ = 0;
153 Size2D<double> size_;
154
155 CodeReader::CompositeType compositeType_;
156 };
157
159
165 class Result final
166 {
167 friend class ResultHandle;
168
169 private:
170 Result(const String &data, const Point2D<int> &center, const std::array<Point2D<int>, 4> &corners,
171 Symbology symbology, DecodeStatus decodeStatus, const Cvb::optional<class Result2D> &result2D = {})
172 : data_(data)
173 , center_(center)
174 , corners_(corners)
175 , symbology_(symbology)
176 , decodeStatus_(decodeStatus)
177 , result2D_(result2D) {};
178
179 Result(String &&data, const Point2D<int> &center, std::array<Point2D<int>, 4> &&corners, Symbology symbology,
180 DecodeStatus decodeStatus, const Cvb::optional<class Result2D> &result2D = {})
181 : data_(std::move(data))
182 , center_(center)
183 , corners_(std::move(corners))
184 , symbology_(symbology)
185 , decodeStatus_(decodeStatus)
186 , result2D_(result2D) {};
187
188 public:
189 Result() = default;
190
192
195 String Data() const
196 {
197 return data_;
198 }
199
201
204 Point2D<int> Center() const noexcept
205 {
206 return center_;
207 }
208
210
213 std::array<Point2D<int>, 4> Corners() const noexcept
214 {
215 return corners_;
216 }
217
219
222 Symbology SymbologyType() const noexcept
223 {
224 return symbology_;
225 }
226
228
232 {
233 return decodeStatus_;
234 }
235
237
243 {
244 return result2D_;
245 }
246
247 private:
248 String data_;
249 Point2D<int> center_;
250 std::array<Point2D<int>, 4> corners_;
251 Symbology symbology_ = Symbology::Unknown;
253
255 };
256 } // namespace CodeReader
257
258 CVB_END_INLINE_NS
259} // namespace Cvb
CodeReader::CompositeType CompositeType() const noexcept
Gets the type of the composite component.
Definition result.hpp:142
int Columns() const noexcept
Gets number of columns in the code.
Definition result.hpp:93
int ErrorCorrectionErasureCodewords() const noexcept
Gets the number of used error correction erasure codewords from a decoded 2D code.
Definition result.hpp:133
int Quality() const noexcept
Gets code quality.
Definition result.hpp:115
Size2D< double > Size() const noexcept
Gets size of the code in pixels.
Definition result.hpp:103
int ErrorCorrectionCodewords() const noexcept
Gets the number of used error correction codewords from a decoded 2D code.
Definition result.hpp:124
int Rows() const noexcept
Gets number of rows in the code.
Definition result.hpp:84
Symbology SymbologyType() const noexcept
Gets symbology type of read code.
Definition result.hpp:222
CodeReader::DecodeStatus DecodeStatus() const noexcept
Gets decoding status of read code.
Definition result.hpp:231
Cvb::optional< class Result2D > Result2D() const noexcept
Gets the result of a 2D code, if available.
Definition result.hpp:242
std::array< Point2D< int >, 4 > Corners() const noexcept
Gets corner coordinates of read code.
Definition result.hpp:213
String Data() const
Gets the decoded decoded data.
Definition result.hpp:195
Point2D< int > Center() const noexcept
Gets center coordinates of read code.
Definition result.hpp:204
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
This class is a replacement for C++17 std::optional.
Definition optional.hpp:61
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T move(T... args)
Namespace for all decoding functionalities.
Definition decl_config_2d_codes.hpp:10
Symbology
Enum class listing all supported symbologies.
Definition decl_config_base.hpp:35
@ Unknown
Unknown symbology.
Definition decl_config_base.hpp:37
@ None
No additional processing is applied.
Definition decl_decoder.hpp:34
CompositeType
Enum class representing the type of composite code.
Definition result.hpp:44
@ None
Is not a composite component.
Definition result.hpp:46
@ CCB
Composite Component B (CC-B).
Definition result.hpp:50
@ CCA
Composite Component A (CC-A).
Definition result.hpp:48
@ CCC
Composite Component C (CC-C).
Definition result.hpp:52
DecodeStatus
Enum class for decoding status.
Definition result.hpp:32
@ Success
Decoding succeeded.
Definition result.hpp:36
@ Failure
Decoding failed.
Definition result.hpp:34
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49