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 Barcode
26 {
27
28 enum class Symbology;
29
31 enum class DecodeStatus
32 {
34 Failure = -1,
36 Success = 100
37 };
38
40
47 {
48 friend class Decoder;
49
50 public:
52
55 enum class CompositeType
56 {
58 None = 0,
60 CCA = CExports::CVBCValueSymbology::CVBCVS_CCA,
62 CCB = CExports::CVBCValueSymbology::CVBCVS_CCB,
64 CCC = CExports::CVBCValueSymbology::CVBCVS_CCC
65 };
66
67 private:
68 Result2D(int quality, int rows, int columns, const Size2D<float> &size, int errorCorrectionErasureCodewords,
69 int errorCorrectionCodewords, const CompositeType compositeType = CompositeType::None)
70 : quality_(quality)
71 , rows_(rows)
72 , columns_(columns)
73 , size_(size)
74 , errorCorrectionCodewords_(errorCorrectionCodewords)
75 , errorCorrectionErasureCodewords_(errorCorrectionErasureCodewords)
76 , compositeType_(compositeType)
77 {
78 }
79
80 public:
82
85 int Rows() const noexcept
86 {
87 return rows_;
88 }
89
91
94 int Columns() const noexcept
95 {
96 return columns_;
97 }
98
100
104 Size2D<float> Size() const noexcept
105 {
106 return size_;
107 }
108
110
115 int Quality() const noexcept
116 {
117 return quality_;
118 }
119
121
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<float> size_;
154
155 enum class CompositeType compositeType_;
156 };
157
159
165 class Result final
166 {
167 friend class Decoder;
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 public:
180 Result() = default;
181
183
186 String Data() const
187 {
188 return data_;
189 }
190
192
195 Point2D<int> Center() const noexcept
196 {
197 return center_;
198 }
199
201
204 std::array<Point2D<int>, 4> Corners() const noexcept
205 {
206 return corners_;
207 }
208
210
213 Symbology SymbologyType() const noexcept
214 {
215 return symbology_;
216 }
217
219
222 DecodeStatus DecodeStatus() const noexcept
223 {
224 return decodeStatus_;
225 }
226
228
234 {
235 return result2D_;
236 }
237
238 private:
239 String data_;
240 Point2D<int> center_;
241 std::array<Point2D<int>, 4> corners_;
242 Symbology symbology_ = Symbology::Unknown;
243 enum class DecodeStatus decodeStatus_ = DecodeStatus::Failure;
244
246 };
247
248 } // namespace Barcode
249
250 CVB_END_INLINE_NS
251} // namespace Cvb
Class for barcode decoding.
Definition: decl_decoder.hpp:73
Class for storing the results of 2D barcode decoding.
Definition: result.hpp:47
CompositeType CompositeType()
Gets the type of the composite component.
Definition: result.hpp:142
CompositeType
Enum class representing the type of composite barcode.
Definition: result.hpp:56
@ None
Is not a composite component.
int ErrorCorrectionErasureCodewords()
Gets the number of used error correction erasure codewords from a decoded 2D barcode.
Definition: result.hpp:133
int Columns() const noexcept
Gets number of columns in the barcode.
Definition: result.hpp:94
int ErrorCorrectionCodewords()
Gets the number of used error correction codewords from a decoded 2D barcode.
Definition: result.hpp:124
int Quality() const noexcept
Gets barcode quality.
Definition: result.hpp:115
Size2D< float > Size() const noexcept
Gets size of the barcode in pixels.
Definition: result.hpp:104
int Rows() const noexcept
Gets number of rows in the barcode.
Definition: result.hpp:85
Class for storing the results of barcode decoding.
Definition: result.hpp:166
Symbology SymbologyType() const noexcept
Gets symbology type of decoded barcode.
Definition: result.hpp:213
Cvb::optional< class Result2D > Result2D() const noexcept
Gets the result of a 2D barcode, if available.
Definition: result.hpp:233
std::array< Point2D< int >, 4 > Corners() const noexcept
Gets corner coordinates of decoded barcode.
Definition: result.hpp:204
DecodeStatus DecodeStatus() const noexcept
Gets decoding status of decoded barcode.
Definition: result.hpp:222
String Data() const
Gets the decoded barcode data.
Definition: result.hpp:186
Point2D< int > Center() const noexcept
Gets center coordinates of decoded barcode.
Definition: result.hpp:195
This class is a replacement for C++17 std::optional.
Definition: optional.hpp:60
Symbology
Enum class listing all supported barcode symbologies.
Definition: decl_config_base.hpp:36
@ Unknown
Unknown barcode symbology.
DecodeStatus
Enum class for decoding status.
Definition: result.hpp:32
@ Success
Decoding succeeded.
@ Failure
Decoding failed.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15