CVB++ 15.0
Loading...
Searching...
No Matches
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
39 namespace CodeReader
40 {
41
42 enum class Symbology;
43
45 enum class DecodeStatus
46 {
48 Failure = -1,
50 Success = 100
51 };
52
54
57 enum class CompositeType
58 {
60 None = 0,
62 CCA = CExports::CVCRValueSymbology::CVCRVS_CCA,
64 CCB = CExports::CVCRValueSymbology::CVCRVS_CCB,
66 CCC = CExports::CVCRValueSymbology::CVCRVS_CCC
67 };
68
70
76 class Result2D
77 {
78 friend class ResultHandle;
79
80 private:
81 Result2D(int quality, int rows, int columns, const Size2D<double> &size, int errorCorrectionErasureCodewords,
82 int errorCorrectionCodewords, const CompositeType compositeType = CompositeType::None)
83 : quality_(quality)
84 , rows_(rows)
85 , columns_(columns)
86 , size_(size)
87 , errorCorrectionCodewords_(errorCorrectionCodewords)
88 , errorCorrectionErasureCodewords_(errorCorrectionErasureCodewords)
89 , compositeType_(compositeType)
90 {
91 }
92
93 public:
95
98 int Rows() const noexcept
99 {
100 return rows_;
101 }
102
104
107 int Columns() const noexcept
108 {
109 return columns_;
110 }
111
113
117 Size2D<double> Size() const noexcept
118 {
119 return size_;
120 }
121
123
129 int Quality() const noexcept
130 {
131 return quality_;
132 }
133
135
138 int ErrorCorrectionCodewords() const noexcept
139 {
140 return errorCorrectionCodewords_;
141 }
142
144
148 {
149 return errorCorrectionErasureCodewords_;
150 }
151
153
157 {
158 return compositeType_;
159 }
160
161 private:
162 int quality_ = 0; // 0-100
163 int errorCorrectionCodewords_ = 0;
164 int errorCorrectionErasureCodewords_ = 0;
165 int rows_ = 0;
166 int columns_ = 0;
167 Size2D<double> size_;
168
169 CodeReader::CompositeType compositeType_;
170 };
171
173
179 class Result final
180 {
181 friend class ResultHandle;
182
183 private:
184 Result(const String &data, const Point2D<int> &center, const std::array<Point2D<int>, 4> &corners,
185 Symbology symbology, DecodeStatus decodeStatus, const Cvb::optional<class Result2D> &result2D = {})
186 : data_(data)
187 , center_(center)
188 , corners_(corners)
189 , symbology_(symbology)
190 , decodeStatus_(decodeStatus)
191 , result2D_(result2D) {};
192
193 Result(String &&data, const Point2D<int> &center, std::array<Point2D<int>, 4> &&corners, Symbology symbology,
194 DecodeStatus decodeStatus, const Cvb::optional<class Result2D> &result2D = {})
195 : data_(std::move(data))
196 , center_(center)
197 , corners_(std::move(corners))
198 , symbology_(symbology)
199 , decodeStatus_(decodeStatus)
200 , result2D_(result2D) {};
201
202 public:
203 Result() = default;
204
206
209 String Data() const
210 {
211 return data_;
212 }
213
215
218 Point2D<int> Center() const noexcept
219 {
220 return center_;
221 }
222
224
229 std::array<Point2D<int>, 4> Corners() const noexcept
230 {
231 return corners_;
232 }
233
235
238 Symbology SymbologyType() const noexcept
239 {
240 return symbology_;
241 }
242
244
248 {
249 return decodeStatus_;
250 }
251
253
258 Cvb::optional<class Result2D> Result2D() const noexcept
259 {
260 return result2D_;
261 }
262
263 private:
264 String data_;
265 Point2D<int> center_;
266 std::array<Point2D<int>, 4> corners_;
267 Symbology symbology_ = Symbology::Unknown;
269
270 Cvb::optional<class Result2D> result2D_;
271 };
272 } // namespace CodeReader
273
274 CVB_END_INLINE_NS
275} // namespace Cvb
CodeReader::CompositeType CompositeType() const noexcept
Gets the type of the composite component.
Definition result.hpp:156
int Columns() const noexcept
Gets number of columns in the code.
Definition result.hpp:107
int ErrorCorrectionErasureCodewords() const noexcept
Gets the number of used error correction erasure codewords from a decoded 2D code.
Definition result.hpp:147
int Quality() const noexcept
Gets code quality.
Definition result.hpp:129
Size2D< double > Size() const noexcept
Gets size of the code in pixels.
Definition result.hpp:117
int ErrorCorrectionCodewords() const noexcept
Gets the number of used error correction codewords from a decoded 2D code.
Definition result.hpp:138
int Rows() const noexcept
Gets number of rows in the code.
Definition result.hpp:98
Symbology SymbologyType() const noexcept
Gets symbology type of read code.
Definition result.hpp:238
CodeReader::DecodeStatus DecodeStatus() const noexcept
Gets decoding status of read code.
Definition result.hpp:247
Cvb::optional< class Result2D > Result2D() const noexcept
Gets the result of a 2D code, if available.
Definition result.hpp:258
std::array< Point2D< int >, 4 > Corners() const noexcept
Gets corner coordinates of read code.
Definition result.hpp:229
String Data() const
Gets the decoded decoded data.
Definition result.hpp:209
Point2D< int > Center() const noexcept
Gets center coordinates of read code.
Definition result.hpp:218
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
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:58
@ None
Is not a composite component.
Definition result.hpp:60
@ CCB
Composite Component B (CC-B).
Definition result.hpp:64
@ CCA
Composite Component A (CC-A).
Definition result.hpp:62
@ CCC
Composite Component C (CC-C).
Definition result.hpp:66
DecodeStatus
Enum class for decoding status.
Definition result.hpp:46
@ Success
Decoding succeeded.
Definition result.hpp:50
@ Failure
Decoding failed.
Definition result.hpp:48
Root namespace for the Image Manager interface.
Definition version.hpp:11
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49