CVB++ 15.0
detail_decoder.hpp
1#pragma once
2
3#include "../result.hpp"
4#include "../_decl/decl_decoder.hpp"
5#include "../_decl/decl_result_handle.hpp"
6
7namespace Cvb
8{
9 CVB_BEGIN_INLINE_NS
10
11 namespace CodeReader
12 {
13
14 inline std::unique_ptr<Decoder> Decoder::FromHandle(HandleGuard<Decoder> &&guard)
15 {
16 if (!guard.Handle())
17 throw std::runtime_error("decoder handle must not be null");
18
19 return std::make_unique<Decoder>(std::move(guard), PrivateTag{});
20 }
21
23 {
24 return Internal::DoResCallObjectOut<Decoder>(
25 [&](void *&handle) { return CVB_CALL_CAPI(CVCRCreateDecoder(handle)); });
26 }
27
28 inline void Decoder::SetBasicInkjetDPMEnabled(bool value)
29 {
30 CVB_CALL_CAPI_CHECKED(
31 CVCRSetPropertyInt(Handle(), static_cast<int>(Properties::BasicInkjet), static_cast<int>(value)));
32 }
33
35 {
36 int value = 0;
37 CVB_CALL_CAPI_CHECKED(CVCRGetPropertyInt(Handle(), static_cast<int>(Properties::BasicInkjet), value));
38 return static_cast<bool>(value);
39 }
40
42 {
43 CVB_CALL_CAPI_CHECKED(
44 CVCRSetPropertyInt(Handle(), static_cast<int>(CExports::CVCRPerformanceProperties::CVCRPP_CustomPerformance),
45 static_cast<int>(value)));
46 }
47
49 {
50 int value = 0;
51 CVB_CALL_CAPI_CHECKED(CVCRGetPropertyInt(
52 Handle(), static_cast<int>(CExports::CVCRPerformanceProperties::CVCRPP_CustomPerformance), value));
53 return static_cast<CodeReader::CustomPerformance>(value);
54 }
55
56 inline void Decoder::SetDetectorDensity(int value)
57 {
58 if (value < 1 || value > 4)
59 throw std::invalid_argument("value for DetectorDensity must be between 1 and 4 (inclusive)");
60
61 CVB_CALL_CAPI_CHECKED(
62 CVCRSetPropertyInt(Handle(), static_cast<int>(CExports::CVCRPerformanceProperties::CVCRPP_DetectorDensity),
63 static_cast<int>(value)));
64 }
65
66 inline int Decoder::DetectorDensity() const
67 {
68 int value = 0;
69 CVB_CALL_CAPI_CHECKED(CVCRGetPropertyInt(
70 Handle(), static_cast<int>(CExports::CVCRPerformanceProperties::CVCRPP_DetectorDensity), value));
71 return value;
72 }
73
74 inline std::vector<Result> Decoder::ExecuteSingleInstance(const ImagePlane &plane, const Rect<int> &aoi)
75 {
76 auto pResult = Internal::DoResCallObjectOut<ResultHandle>([&](void *&handle) {
77 return CVB_CALL_CAPI(CVCRDecodeMultiImageWithResultRect(Handle(), plane.Handle(), 0, aoi.Left(), aoi.Top(),
78 aoi.Right(), aoi.Bottom(), 0, 0, handle));
79 });
80
81 return pResult->CreateResultVector();
82 }
83
84 inline std::vector<Result> Decoder::ExecuteSingleInstance(const ImagePlane &plane)
85 {
86 const auto size = plane.Parent().Size();
87 const auto aoi = Rect<int>(0, 0, size.Width() - 1, size.Height() - 1);
88
89 return ExecuteSingleInstance(plane, aoi);
90 }
91
93 {
94 auto pResult = Internal::DoResCallObjectOut<ResultHandle>([&](void *&handle) {
95 return CVB_CALL_CAPI(CVCRDecodeMultiImageParallelizableRect(Handle(), plane.Handle(), 0, aoi.Left(), aoi.Top(),
96 aoi.Right(), aoi.Bottom(), 0, handle));
97 });
98
99 return pResult->CreateResultVector();
100 }
101
103 {
104 const auto size = plane.Parent().Size();
105 const auto aoi = Rect<int>(0, 0, size.Width() - 1, size.Height() - 1);
106
107 return Execute(plane, aoi);
108 }
109 } // namespace CodeReader
110
111 CVB_END_INLINE_NS
112
113} // namespace Cvb
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
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
Size2D< int > Size() const noexcept
Size of the image in pixels.
Definition decl_image.hpp:428
Image plane information container.
Definition decl_image_plane.hpp:29
void * Handle() const noexcept override
Classic API image handle.
Definition detail_image_plane.hpp:35
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition detail_image_plane.hpp:87
Rectangle object.
Definition rect.hpp:24
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
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17