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 };
110
111 enum class ResultProperties
112 {
113 Corners = CExports::CVCRResultProperties::CVCRRP_Corners,
114 Center = CExports::CVCRResultProperties::CVCRRP_Center,
115 SymbolType = CExports::CVCRResultProperties::CVCRRP_SymbolType,
116 SymbolTypeEx = CExports::CVCRResultProperties::CVCRRP_SymbolTypeEx,
117 Length = CExports::CVCRResultProperties::CVCRRP_Length,
118 String = CExports::CVCRResultProperties::CVCRRP_String,
119 Quality = CExports::CVCRResultProperties::CVCRRP_Quality,
120 Status = CExports::CVCRResultProperties::CVCRRP_Status,
121
122 // Result properties 2D codes
123 ECCError = CExports::CVCRResultProperties2D::CVCRRP2D_ECCError,
124 ECCErasure = CExports::CVCRResultProperties2D::CVCRRP2D_ECCErasure,
125 SymbolHeightWidth = CExports::CVCRResultProperties2D::CVCRRP2D_SymbolHeightWidth,
126 SymbolRowsColumns = CExports::CVCRResultProperties2D::CVCRRP2D_SymbolRowsColumns
127 };
128
129 struct PrivateTag
130 {
131 };
132
133 public:
135
139
148 std::vector<Result> ExecuteSingleInstance(const ImagePlane &plane, const Rect<int> &aoi);
149
164 std::vector<Result> ExecuteSingleInstance(const ImagePlane &plane);
165
167
174 std::vector<Result> Execute(const ImagePlane &plane, const Rect<int> &aoi);
175
177
184
186
206 template <Symbology SYM>
207 typename Config::Mapper<SYM>::Type &Config()
208 {
209 return std::get<typename Config::Mapper<SYM>::Type>(config_);
210 }
211
213
218 void SetBasicInkjetDPMEnabled(bool value);
219
221
224 bool IsBasicInkjetDPMEnabled() const;
225
227
232
234
238
240
247 void SetDetectorDensity(int value);
248
250
254 int DetectorDensity() const;
255
256 private:
257 Decoder(Decoder &&other) noexcept
258 : handle_(std::move(other.handle_))
259 , config_(std::move(other.config_))
260 {
261 }
262
263 public:
264 Decoder(const Decoder &other) = delete;
265 Decoder &operator=(const Decoder &other) = delete;
266 explicit Decoder(HandleGuard<Decoder> &&guard, PrivateTag) noexcept
267 : handle_(std::move(guard))
268 , config_(std::make_tuple(Config::DataMatrix(*this), Config::QR(*this), Config::MicroQR(*this),
269 Config::Pdf417(*this), Config::MicroPdf417(*this), Config::GS1DataBar14(*this),
270 Config::GS1DataBarStacked(*this), Config::GS1DataBarLimited(*this),
271 Config::GS1DataBarExpanded(*this), Config::GS1DataBarExpandedStacked(*this),
272 Config::Ean8(*this), Config::Ean13(*this), Config::UpcA(*this), Config::UpcE(*this),
273 Config::Code128(*this), Config::Code39(*this), Config::Code93(*this),
274 Config::Interleaved2of5(*this), Config::UspsIntelligentMail(*this),
275 Config::DutchPost(*this), Config::AustraliaPost(*this), Config::RoyalMail(*this),
276 Config::Pharmacode(*this), Config::Code32(*this), Config::Code11(*this)))
277 {
278 }
279 virtual ~Decoder() = default;
280
281 static std::unique_ptr<Decoder> FromHandle(HandleGuard<Decoder> &&guard);
282
283 void *Handle() const noexcept
284 {
285 return handle_.Handle();
286 }
287
288 private:
289 HandleGuard<Decoder> handle_;
290 std::tuple<Config::DataMatrix, Config::QR, Config::MicroQR, Config::Pdf417, Config::MicroPdf417,
291 Config::GS1DataBar14, Config::GS1DataBarStacked, Config::GS1DataBarLimited, Config::GS1DataBarExpanded,
292 Config::GS1DataBarExpandedStacked, Config::Ean8, Config::Ean13, Config::UpcA, Config::UpcE,
293 Config::Code128, Config::Code39, Config::Code93, Config::Interleaved2of5, Config::UspsIntelligentMail,
294 Config::DutchPost, Config::AustraliaPost, Config::RoyalMail, Config::Pharmacode, Config::Code32,
295 Config::Code11>
296 config_;
297 };
298 } // namespace CodeReader
299
300 CVB_END_INLINE_NS
301} // 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:56
CodeReader::CustomPerformance CustomPerformance() const
Retrieves the custom image processing method used to optimize decoding robustness and performance.
Definition detail_decoder.hpp:48
bool IsBasicInkjetDPMEnabled() const
Checks whether the Basic Inkjet DPM mode is enabled.
Definition detail_decoder.hpp:34
int DetectorDensity() const
Retrieves the detector density to control the search aggressiveness for small codes.
Definition detail_decoder.hpp:66
Config::Mapper< SYM >::Type & Config()
Retrieves the configuration object for a specific symbology.
Definition decl_decoder.hpp:207
std::vector< Result > Execute(const ImagePlane &plane, const Rect< int > &aoi)
Performs the decoding.
Definition detail_decoder.hpp:92
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:41
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