CVB++ 15.0
barcode_grading.hpp
1#pragma once
2
3#include "../../_cexports/c_barcode.h"
4#include "grader_config_base.hpp"
5
6namespace Cvb
7{
8 CVB_BEGIN_INLINE_NS
9
10 namespace Barcode
11 {
12
14
17 {
18 public:
19
21
26 void SetGradeDecode(bool decode)
27 {
28 SetDirty();
29 decode_ = decode;
30 };
31
33
38 bool GradeDecode() const
39 {
40 return decode_;
41 };
42
44
49 void SetGradeReflectanceMin(bool reflectanceMin)
50 {
51 SetDirty();
52 reflectanceMin_ = reflectanceMin;
53 };
54
56
62 {
63 return reflectanceMin_;
64 };
65
66
68
73 void SetGradeEdgeContrastMin(bool edgeContrastMin)
74 {
75 SetDirty();
76 edgeContrastMin_ = edgeContrastMin;
77 };
78
80
86 {
87 return edgeContrastMin_;
88 };
89
90
92
97 void SetGradeDefects(bool defects)
98 {
99 SetDirty();
100 defects_ = defects;
101 };
102
104
109 bool GradeDefects() const
110 {
111 return defects_;
112 };
113
114
116
121 void SetGradeDecodability(bool decodability)
122 {
123 SetDirty();
124 decodability_ = decodability;
125 };
126
128
133 bool GradeDecodability() const
134 {
135 return decodability_;
136 };
137
138 protected:
139 SmartBool decode_;
140 SmartBool reflectanceMin_;
141 SmartBool edgeContrastMin_;
142 SmartBool defects_;
143 SmartBool decodability_;
144
145 public:
146 virtual Symbology Type() const override { return Symbology::BarcodeGrading; };
147
149
155 static std::unique_ptr<BarcodeGrading> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
156 {
158 isActiveOut = pConfig->ReadFromHandle(guard);
159 return pConfig;
160 }
161
162 protected:
163 virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
164 {
165 short rMin, rMax;
166 CExports::cvbbool_t active;
167 CVB_CALL_CAPI(CvcBcGetCodeGrading1DEx(reinterpret_cast<std::intptr_t>(guard.Handle()),
168 &active,
169 &rMin,
170 &rMax,
171 decode_.Ptr(),
172 reflectanceMin_.Ptr(),
173 symbolContrast_.Ptr(),
174 edgeContrastMin_.Ptr(),
175 modulation_.Ptr(),
176 defects_.Ptr(),
177 decodability_.Ptr()));
178 reflectanceReference_ = Cvb::ValueRange<int>(rMin, rMax);
179
180 return SmartBool(active);
181 }
182
183 virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
184 {
185 Internal::DoResCall([&]()
186 {
187 return CVB_CALL_CAPI(CvcBcSetCodeGrading1DEx(reinterpret_cast<intptr_t>(guard.Handle()),
188 SmartBool(active),
189 static_cast<short>(reflectanceReference_.Min()), static_cast<short>(reflectanceReference_.Max()),
190 decode_,
191 reflectanceMin_,
192 symbolContrast_,
193 edgeContrastMin_,
194 modulation_,
195 defects_,
196 decodability_));
197 });
198 }
199
200 BarcodeGrading()
201 : GraderConfigBase()
202 {
203 }
204
205
206 };
207
208 using BarcodeGradingPtr = std::shared_ptr<BarcodeGrading>;
209 }
210
211 CVB_END_INLINE_NS
212}
Configuration to access parameters of barcode grading.
Definition: barcode_grading.hpp:17
bool GradeReflectanceMin() const
Returns whether or not the grade GradeResult1D::ReflectanceMin will enter the calculation of GradeRes...
Definition: barcode_grading.hpp:61
bool GradeDecode() const
Returns whether or not the grade decodes will enter the calculation of GradeResult1D::GradeOverall.
Definition: barcode_grading.hpp:38
void SetGradeDefects(bool defects)
Specifies whether or not the grade GradeResult1D::Defects will enter the calculation of GradeResult1D...
Definition: barcode_grading.hpp:97
void SetGradeDecodability(bool decodability)
Specifies whether or not the grade GradeResult1D::Decodability will enter the calculation of GradeRes...
Definition: barcode_grading.hpp:121
void SetGradeReflectanceMin(bool reflectanceMin)
Specifies whether or not the grade GradeResult1D::ReflectanceMin will enter the calculation of GradeR...
Definition: barcode_grading.hpp:49
static std::unique_ptr< BarcodeGrading > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: barcode_grading.hpp:155
bool GradeDefects() const
Returns whether or not the grade GradeResult1D::Defects will enter the calculation of GradeResult1D::...
Definition: barcode_grading.hpp:109
void SetGradeEdgeContrastMin(bool edgeContrastMin)
Specifies whether or not the grade GradeResult1D::EdgeContrastMin will enter the calculation of Grade...
Definition: barcode_grading.hpp:73
bool GradeDecodability() const
Returns whether or not the grade GradeResult1D::Decodability will enter the calculation of GradeResul...
Definition: barcode_grading.hpp:133
void SetGradeDecode(bool decode)
Specifies whether or not the grade decodes will enter the calculation of GradeResult1D::GradeOverall.
Definition: barcode_grading.hpp:26
bool GradeEdgeContrastMin() const
Returns whether or not the grade GradeResult1D::EdgeContrastMin will enter the calculation of GradeRe...
Definition: barcode_grading.hpp:85
Configuration to access parameters of GraderConfigBase.
Definition: grader_config_base.hpp:20
T Min() const noexcept
Gets the minimum value.
Definition: value_range.hpp:50
T Max() const noexcept
Gets the maximum value.
Definition: value_range.hpp:72
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ BarcodeGrading
1D Barcode grading
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24