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_code_reader.h"
12#include "decl_config.hpp"
13#include "../result.hpp"
14
15namespace Cvb
16{
17 CVB_BEGIN_INLINE_NS
18
19 template <>
20 inline HandleGuard<CodeReader::Decoder>::HandleGuard(void *handle) noexcept
21 : HandleGuard<CodeReader::Decoder>(handle, [](void *handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
22 {
23 }
24
25 namespace CodeReader
26 {
28
32 {
34 None = CExports::CVCRCustomPerformance::CVCRCP_None,
35
37
44 Robust = CExports::CVCRCustomPerformance::CVCRCP_Robust,
45
47
52 ExtendedRange2D = CExports::CVCRCustomPerformance::CVCRCP_ExtendedRange2D
53 };
54
56
100 class Decoder final
101 {
102 template <class T>
103 friend class ConfigBase;
104
105 private:
106 enum class Properties
107 {
108 BasicInkjet = CExports::CVCRPerformanceProperties::CVCRPP_BasicInkjet,
109 AllCommon1DCodes = 124,
110 All2DCodes = 125
111 };
112
113 enum class ResultProperties
114 {
115 Corners = CExports::CVCRResultProperties::CVCRRP_Corners,
116 Center = CExports::CVCRResultProperties::CVCRRP_Center,
117 SymbolType = CExports::CVCRResultProperties::CVCRRP_SymbolType,
118 SymbolTypeEx = CExports::CVCRResultProperties::CVCRRP_SymbolTypeEx,
119 Length = CExports::CVCRResultProperties::CVCRRP_Length,
120 String = CExports::CVCRResultProperties::CVCRRP_String,
121 Quality = CExports::CVCRResultProperties::CVCRRP_Quality,
122 Status = CExports::CVCRResultProperties::CVCRRP_Status,
123
124 // Result properties 2D codes
125 ECCError = CExports::CVCRResultProperties2D::CVCRRP2D_ECCError,
126 ECCErasure = CExports::CVCRResultProperties2D::CVCRRP2D_ECCErasure,
127 SymbolHeightWidth = CExports::CVCRResultProperties2D::CVCRRP2D_SymbolHeightWidth,
128 SymbolRowsColumns = CExports::CVCRResultProperties2D::CVCRRP2D_SymbolRowsColumns
129 };
130
131 struct PrivateTag
132 {
133 };
134
135 public:
137
141
150 std::vector<Result> ExecuteSingleInstance(const ImagePlane &plane, const Rect<int> &aoi);
151
166 std::vector<Result> ExecuteSingleInstance(const ImagePlane &plane);
167
169
176 std::vector<Result> Execute(const ImagePlane &plane, const Rect<int> &aoi);
177
179
186
188
208 template <Symbology SYM>
209 typename Config::Mapper<SYM>::Type &Config()
210 {
211 return std::get<typename Config::Mapper<SYM>::Type>(config_);
212 }
213
215
220 void SetBasicInkjetDPMEnabled(bool value);
221
223
226 bool IsBasicInkjetDPMEnabled() const;
227
229
233 void SetAllCommon1DCodesEnabled(bool value);
234
236
239 bool AllCommon1DCodesEnabled() const;
240
242
245 void SetAll2DCodesEnabled(bool value);
246
248
251 bool All2DCodesEnabled() const;
252
254
259
261
265
267
274 void SetDetectorDensity(int value);
275
277
281 int DetectorDensity() const;
282
283 private:
284 Decoder(Decoder &&other) noexcept
285 : handle_(std::move(other.handle_))
286 , config_(std::move(other.config_))
287 {
288 }
289
290 public:
291 Decoder(const Decoder &other) = delete;
292 Decoder &operator=(const Decoder &other) = delete;
293 explicit Decoder(HandleGuard<Decoder> &&guard, PrivateTag) noexcept
294 : handle_(std::move(guard))
295 , config_(std::make_tuple(Config::DataMatrix(*this), Config::QR(*this), Config::MicroQR(*this),
296 Config::Pdf417(*this), Config::MicroPdf417(*this), Config::GS1DataBar14(*this),
297 Config::GS1DataBarStacked(*this), Config::GS1DataBarLimited(*this),
298 Config::GS1DataBarExpanded(*this), Config::GS1DataBarExpandedStacked(*this),
299 Config::Ean8(*this), Config::Ean13(*this), Config::UpcA(*this), Config::UpcE(*this),
300 Config::Code128(*this), Config::Code39(*this), Config::Code93(*this),
301 Config::Interleaved2of5(*this), Config::UspsIntelligentMail(*this),
302 Config::DutchPost(*this), Config::AustraliaPost(*this), Config::RoyalMail(*this),
303 Config::Pharmacode(*this), Config::Code32(*this), Config::Code11(*this)))
304 {
305 }
306 virtual ~Decoder() = default;
307
308 static std::unique_ptr<Decoder> FromHandle(HandleGuard<Decoder> &&guard);
309
310 void *Handle() const noexcept
311 {
312 return handle_.Handle();
313 }
314
315 private:
316 HandleGuard<Decoder> handle_;
317 std::tuple<Config::DataMatrix, Config::QR, Config::MicroQR, Config::Pdf417, Config::MicroPdf417,
318 Config::GS1DataBar14, Config::GS1DataBarStacked, Config::GS1DataBarLimited, Config::GS1DataBarExpanded,
319 Config::GS1DataBarExpandedStacked, Config::Ean8, Config::Ean13, Config::UpcA, Config::UpcE,
320 Config::Code128, Config::Code39, Config::Code93, Config::Interleaved2of5, Config::UspsIntelligentMail,
321 Config::DutchPost, Config::AustraliaPost, Config::RoyalMail, Config::Pharmacode, Config::Code32,
322 Config::Code11>
323 config_;
324 };
325 } // namespace CodeReader
326
327 CVB_END_INLINE_NS
328} // namespace Cvb
Class for decoding.
Definition decl_decoder.hpp:101
void SetDetectorDensity(int value)
Sets the detector density to control the search aggressiveness for small codes.
Definition detail_decoder.hpp:82
CodeReader::CustomPerformance CustomPerformance() const
Retrieves the custom image processing method used to optimize decoding robustness and performance.
Definition detail_decoder.hpp:74
bool IsBasicInkjetDPMEnabled() const
Checks whether the Basic Inkjet DPM mode is enabled.
Definition detail_decoder.hpp:34
void SetAll2DCodesEnabled(bool value)
Enables all 2D codes.
Definition detail_decoder.hpp:54
bool AllCommon1DCodesEnabled() const
Checks whether all common 1D codes are enabled.
Definition detail_decoder.hpp:47
bool All2DCodesEnabled() const
Checks whether all 2D codes are enabled.
Definition detail_decoder.hpp:60
void SetAllCommon1DCodesEnabled(bool value)
Enables all common 1D codes.
Definition detail_decoder.hpp:41
int DetectorDensity() const
Retrieves the detector density to control the search aggressiveness for small codes.
Definition detail_decoder.hpp:92
Config::Mapper< SYM >::Type & Config()
Retrieves the configuration object for a specific symbology.
Definition decl_decoder.hpp:209
std::vector< Result > Execute(const ImagePlane &plane, const Rect< int > &aoi)
Performs the decoding.
Definition detail_decoder.hpp:118
static std::unique_ptr< Decoder > Create()
Creates and returns a new Decoder instance.
Definition detail_decoder.hpp:22
void SetCustomPerformance(CustomPerformance value)
Sets the custom image processing method used to optimize decoding robustness and performance.
Definition detail_decoder.hpp:67
void SetBasicInkjetDPMEnabled(bool value)
Enables or disables the reading of Basic Inkjet DPM (Direct Part Marking) codes.
Definition detail_decoder.hpp:28
Image plane information container.
Definition decl_image_plane.hpp:29
Rectangle object.
Definition rect.hpp:24
cvbbool_t ReleaseObject(OBJ &Object)
T make_tuple(T... args)
T move(T... args)
Namespace for all decoding functionalities.
Definition decl_config_2d_codes.hpp:10
CustomPerformance
Enum class specifying custom image processing methods to improve decoding robustness and performance.
Definition decl_decoder.hpp:32
@ ExtendedRange2D
Extends the readable range for 2D codes in the central area of the image.
Definition decl_decoder.hpp:52
@ None
No additional processing is applied.
Definition decl_decoder.hpp:34
@ Robust
Enables robust decoding for a single code.
Definition decl_decoder.hpp:44
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17