CVB++ 15.0
decl_decoder.hpp
1#pragma once
2
3#include <tuple>
4
5#include "../shims/stdoptional.hpp"
6
7#include "../../global.hpp"
8#include "../../image.hpp"
9#include "../../rect.hpp"
10
11#include "../../_cexports/c_barcode.h"
12#include "decl_config.hpp"
13#include "../result.hpp"
14
15
16namespace Cvb
17{
18 CVB_BEGIN_INLINE_NS
19
20 template <>
21 inline HandleGuard<Barcode::Decoder>::HandleGuard(void *handle) noexcept
22 : HandleGuard<Barcode::Decoder>(handle, [](void *handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
23 {
24 }
25
26 namespace Barcode
27 {
29
72 class Decoder final
73 {
74 template <class T>
75 friend class ConfigBase;
76
77 enum class Properties
78 {
79 BasicInkjet = 370
80 };
81
82 enum class ResultProperties
83 {
84 Corners = CExports::CVBCResultProperties::CVBCRP_Corners,
85 Center = CExports::CVBCResultProperties::CVBCRP_Center,
86 SymbolType = CExports::CVBCResultProperties::CVBCRP_SymbolType,
87 SymbolTypeEx = CExports::CVBCResultProperties::CVBCRP_SymbolTypeEx,
88 Length = CExports::CVBCResultProperties::CVBCRP_Length,
89 String = CExports::CVBCResultProperties::CVBCRP_String,
90 Quality = CExports::CVBCResultProperties::CVBCRP_Quality,
91 Status = CExports::CVBCResultProperties::CVBCRP_Status,
92
93 // Result properties 2D barcodes
94 ECCError = CExports::CVBCResultProperties2D::CVBCRP2D_ECCError,
95 ECCErasure = CExports::CVBCResultProperties2D::CVBCRP2D_ECCErasure,
96 SymbolHeightWidth = CExports::CVBCResultProperties2D::CVBCRP2D_SymbolHeightWidth,
97 SymbolRowsColumns = CExports::CVBCResultProperties2D::CVBCRP2D_SymbolRowsColumns
98 };
99
100 struct PrivateTag{};
101
102 public:
104
108
110
116
118
123
124
126
146 template <Symbology SYM>
147 typename Config::Mapper<SYM>::Type &Config()
148 {
149 return std::get<typename Config::Mapper<SYM>::Type>(config_);
150 }
151
153
158 void SetEnableBasicInkjetDPM(bool value);
159
161
164 bool EnabledBasicInkjetDPM() const;
165
166
167 private:
168 Decoder(Decoder &&other) noexcept
169 : handle_(std::move(other.handle_))
170 , config_(std::move(other.config_))
171 {
172 }
173
174 int GetIntProperty(ResultProperties property, int index);
175 String GetPropertyString(ResultProperties property, int index);
176 std::vector<int> GetStructProperty(ResultProperties property, int index);
177
178 Symbology GetSymbology(int index);
179 Point2D<int> GetCenter(int index);
180 std::array<Point2D<int>, 4> GetCorners(int index);
181
182 bool SymbolContainsCompositeType(int symbol, enum class Result2D::CompositeType compositeType);
183 enum class Result2D::CompositeType GetCompositeType(int index);
184
185 float ConvertSizeToPixelCount(int value);
186 Cvb::optional<Result2D> GetResult2D(int index);
187 Result GetResult(int index);
188 std::vector<Result> CreateResultVector(int numSymbolsDetected);
189
190 public:
191 Decoder(const Decoder &other) = delete;
192 Decoder &operator=(const Decoder &other) = delete;
193 explicit Decoder(HandleGuard<Decoder> &&guard, PrivateTag) noexcept
194 : handle_(std::move(guard))
195 , config_(std::make_tuple(
196 Config::DataMatrix(*this),
197 Config::QR(*this),
198 Config::MicroQR(*this),
199 Config::Pdf417(*this),
200 Config::MicroPdf417(*this),
201 Config::GS1DataBar14(*this),
202 Config::GS1DataBarStacked(*this),
203 Config::GS1DataBarLimited(*this),
204 Config::GS1DataBarExpanded(*this),
205 Config::GS1DataBarExpandedStacked(*this),
206 Config::Ean8(*this),
207 Config::Ean13(*this),
208 Config::UpcA(*this),
209 Config::UpcE(*this),
210 Config::Code128(*this),
211 Config::Code39(*this),
212 Config::Code93(*this),
213 Config::Interleaved2of5(*this),
214 Config::UspsIntelligentMail(*this),
215 Config::DutchPost(*this),
216 Config::AustraliaPost(*this),
217 Config::RoyalMail(*this),
218 Config::Pharmacode(*this),
219 Config::Code32(*this),
220 Config::Code11(*this)))
221 {
222 }
223 virtual ~Decoder() = default;
224
225 static std::unique_ptr<Decoder> FromHandle(HandleGuard<Decoder> &&guard);
226
227 void *Handle() const noexcept
228 {
229 return handle_.Handle();
230 }
231
232 private:
233 HandleGuard<Decoder> handle_;
235 Config::DataMatrix,
236 Config::QR,
237 Config::MicroQR,
238 Config::Pdf417,
239 Config::MicroPdf417,
240 Config::GS1DataBar14,
241 Config::GS1DataBarStacked,
242 Config::GS1DataBarLimited,
243 Config::GS1DataBarExpanded,
244 Config::GS1DataBarExpandedStacked,
245 Config::Ean8,
246 Config::Ean13,
247 Config::UpcA,
248 Config::UpcE,
249 Config::Code128,
250 Config::Code39,
251 Config::Code93,
252 Config::Interleaved2of5,
253 Config::UspsIntelligentMail,
254 Config::DutchPost,
255 Config::AustraliaPost,
256 Config::RoyalMail,
257 Config::Pharmacode,
258 Config::Code32,
259 Config::Code11>
260 config_;
261 };
262 } // namespace Barcode
263
264 CVB_END_INLINE_NS
265} // namespace Cvb
Class for barcode decoding.
Definition: decl_decoder.hpp:73
void SetEnableBasicInkjetDPM(bool value)
Enables or disables the reading of Basic Inkjet DPM (Direct Part Marking) codes.
Definition: detail_decoder.hpp:28
bool EnabledBasicInkjetDPM() const
Checks whether the Basic Inkjet DPM mode is enabled.
Definition: detail_decoder.hpp:34
Config::Mapper< SYM >::Type & Config()
Retrieves the configuration object for a specific barcode symbology.
Definition: decl_decoder.hpp:147
static std::unique_ptr< Decoder > Create()
Creates and returns a new Decoder instance.
Definition: detail_decoder.hpp:22
std::vector< Result > Execute(const ImagePlane &plane, Rect< int > aoi)
Performs the barcode decoding.
Definition: detail_decoder.hpp:41
CompositeType
Enum class representing the type of composite barcode.
Definition: result.hpp:56
Image plane information container.
Definition: decl_image_plane.hpp:33
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
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15