3#include "../_cexports/c_barcode.h"
7#include "_detail/config_base.hpp"
8#include "_detail/barcode_grading.hpp"
9#include "_detail/data_matrix_grading.hpp"
10#include "_detail/qr_grading.hpp"
11#include "_detail/qr.hpp"
13#include "_detail/codabar.hpp"
14#include "_detail/code11.hpp"
15#include "_detail/code32.hpp"
16#include "_detail/discrete_2_of_5.hpp"
17#include "_detail/ean8.hpp"
18#include "_detail/ean13.hpp"
19#include "_detail/four_state_australian.hpp"
20#include "_detail/four_state_kix.hpp"
21#include "_detail/four_state_royal_mail.hpp"
22#include "_detail/four_state_usps.hpp"
23#include "_detail/interleaved_2_of_5.hpp"
24#include "_detail/micro_pdf417.hpp"
25#include "_detail/msi_plessey.hpp"
26#include "_detail/pharma_code.hpp"
27#include "_detail/planet.hpp"
28#include "_detail/postnet.hpp"
29#include "_detail/rss.hpp"
30#include "_detail/upc_a.hpp"
31#include "_detail/upc_e.hpp"
32#include "_detail/pdf417.hpp"
33#include "_detail/data_matrix.hpp"
34#include "_detail/qr.hpp"
35#include "_detail/sony_code.hpp"
36#include "_detail/code128.hpp"
37#include "_detail/code39.hpp"
38#include "_detail/code93.hpp"
51 inline HandleGuard<Barcode::ReaderConfig>::HandleGuard(
void * handle) noexcept
52 : HandleGuard<Barcode::ReaderConfig>(handle, [](
void* handle) { CVB_CALL_CAPI(CvcBcDeleteConfiguration(
reinterpret_cast<intptr_t
>(handle))); })
67 return Internal::DoResCallObjectOut<ReaderConfig>([&](
void* & configOut)
70 return CExports::CVC_E_OK;
82 return handle_.Handle();
112 Internal::DoResCall([&]()
114 return CVB_CALL_CAPI(CvcBcLoadConfigurationTyped(
reinterpret_cast<intptr_t
>(pConfig->Handle()), fileName.c_str()));
116 pConfig->UpdateMap();
131 Internal::DoResCall([&]()
133 return CVB_CALL_CAPI(CvcBcSaveConfigurationTyped(
reinterpret_cast<intptr_t
>(handle_.Handle()), fileName.c_str()));
144 for (
auto pair : configMap_)
145 pair.second->WriteToHandle(
true, handle_);
155 template<
typename TConfig>
160 if (TrySearchConfiguration<TConfig>(pConfig))
173 template<
typename TConfig>
176 if (
auto config = Configuration<TConfig>())
180 auto& configId =
typeid(TConfig);
181 if (
auto FromHandle = TypeIdCtorMapping.at(configId))
183 bool isCurrentlyActive =
false;
184 if (
auto newConfig =
FromHandle(handle_, isCurrentlyActive))
186 InsertConfiguration(configId, newConfig);
187 return std::dynamic_pointer_cast<TConfig>(newConfig);
204 template<
typename TConfig>
222 readoutMode_ = readoutMode;
246 Internal::DoResCall([&]()
248 return CVB_CALL_CAPI(CvcBcSetReadout(
reinterpret_cast<std::intptr_t>(handle_.Handle()),
251 static_cast<short>(range)));
266 short numStripes = 0;
268 CVB_CALL_CAPI(CvcBcGetReadout(
reinterpret_cast<std::intptr_t>(handle_.Handle()), &numAngle, &numStripes, &range));
269 return static_cast<int>(range);
282 Internal::DoResCall([&]()
284 return CVB_CALL_CAPI(CvcBcSetReadout(
reinterpret_cast<std::intptr_t>(handle_.Handle()),
285 static_cast<short>(numAngle),
302 short numStripes = 0;
304 CVB_CALL_CAPI(CvcBcGetReadout(
reinterpret_cast<std::intptr_t>(handle_.Handle()), &numAngle, &numStripes, &range));
305 return static_cast<int>(numAngle);
318 Internal::DoResCall([&]()
320 return CVB_CALL_CAPI(CvcBcSetReadout(
reinterpret_cast<std::intptr_t>(handle_.Handle()),
322 static_cast<short>(numStripe),
338 short numStripes = 0;
340 CVB_CALL_CAPI(CvcBcGetReadout(
reinterpret_cast<std::intptr_t>(handle_.Handle()), &numAngle, &numStripes, &range));
341 return static_cast<int>(numStripes);
355 Internal::DoResCall([&]()
357 return CVB_CALL_CAPI(CvcBcSetCodePositionCheck(
reinterpret_cast<std::intptr_t>(handle_.Handle()), SmartBool(checkPosition)));
372 SmartBool checkPosition(
false);
373 CVB_CALL_CAPI(CvcBcGetCodePositionCheck(
reinterpret_cast<std::intptr_t>(handle_.Handle()), checkPosition.Ptr()));
374 return checkPosition;
391 CVB_CALL_CAPI(CvcBcSetTimeLimit(
reinterpret_cast<std::intptr_t>(handle_.Handle()),
static_cast<short>(timeLimit)));
408 CVB_CALL_CAPI(CvcBcGetTimeLimit(
reinterpret_cast<std::intptr_t>(handle_.Handle()), &timeLimit));
409 return static_cast<int>(timeLimit);
421 for (
auto pair : TypeIdSymbologyMapping)
423 auto tmpSymbology = pair.second;
424 auto& tmpId = pair.first;
425 if (tmpSymbology == symbology)
426 if (configMap_.count(tmpId) >= 1)
449 ReaderConfig(HandleGuard<ReaderConfig>&& guard) noexcept
450 : handle_(std::move(guard))
456 ReaderConfig(ReaderConfig && other) =
default;
458 ReaderConfig & operator=(ReaderConfig && other) =
default;
463 configMap_ = InitConfigMap(handle_);
470 for (
auto pair : TypeIdCtorMapping)
472 auto&
id = pair.first;
474 bool isActive =
false;
483 template<
typename TConfig>
488 for (
auto const& pair : configMap_)
489 if (
auto tmpConfig = std::dynamic_pointer_cast<TConfig>(pair.second))
491 configOut = tmpConfig;
503 void InsertConfiguration(
std::type_index configId, ConfigBasePtr configuration)
514 if (
auto config = configMap_.at(configId))
516 config->WriteToHandle(
false, handle_);
517 configMap_.erase(configId);
520 throw std::runtime_error(
"Failed to remove barcode symbology from configuration. Not available/active.");
525 HandleGuard<ReaderConfig> handle_;
535 using Barcode::ReaderConfig;
Configuration to access parameters of barcode grading.
Definition: barcode_grading.hpp:17
static std::unique_ptr< BarcodeGrading > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: barcode_grading.hpp:155
Configuration to access parameters of Codabar.
Definition: codabar.hpp:18
static std::unique_ptr< Codabar > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: codabar.hpp:30
Configuration to access parameters of Code11.
Definition: code11.hpp:17
static std::unique_ptr< Code11 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: code11.hpp:60
Configuration to access parameters of Code128.
Definition: code128.hpp:18
static std::unique_ptr< Code128 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: code128.hpp:31
Configuration to access parameters of Code32.
Definition: code32.hpp:17
static std::unique_ptr< Code32 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: code32.hpp:84
Configuration to access parameters of Code39.
Definition: code39.hpp:18
static std::unique_ptr< Code39 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: code39.hpp:60
Configuration to access parameters of Code93.
Definition: code93.hpp:18
static std::unique_ptr< Code93 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: code93.hpp:31
Configuration to access parameters of DataMatrixGrading.
Definition: data_matrix_grading.hpp:17
static std::unique_ptr< DataMatrixGrading > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: data_matrix_grading.hpp:58
Configuration to access parameters of DataMatrix.
Definition: data_matrix.hpp:18
static std::unique_ptr< DataMatrix > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: data_matrix.hpp:588
Configuration to access parameters of Discrete2of5.
Definition: discrete_2_of_5.hpp:17
static std::unique_ptr< Discrete2of5 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: discrete_2_of_5.hpp:30
Configuration to access parameters of Ean13.
Definition: ean13.hpp:17
static std::unique_ptr< Ean13 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: ean13.hpp:29
Configuration to access parameters of Ean8.
Definition: ean8.hpp:17
static std::unique_ptr< Ean8 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: ean8.hpp:29
Configuration to access parameters of FourStateAustralian (4-State Australian).
Definition: four_state_australian.hpp:17
static std::unique_ptr< FourStateAustralian > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: four_state_australian.hpp:85
Configuration to access parameters of FourStateKix.
Definition: four_state_kix.hpp:17
static std::unique_ptr< FourStateKix > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: four_state_kix.hpp:119
Configuration to access parameters of FourStateRoyalMail (4-State RoyalMail Postal Code).
Definition: four_state_royal_mail.hpp:18
static std::unique_ptr< FourStateRoyalMail > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: four_state_royal_mail.hpp:198
Configuration to access parameters of FourStateUsps.
Definition: four_state_usps.hpp:17
static std::unique_ptr< FourStateUsps > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: four_state_usps.hpp:59
Configuration to access parameters of Interleaved2of5.
Definition: interleaved_2_of_5.hpp:17
static std::unique_ptr< Interleaved2of5 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: interleaved_2_of_5.hpp:29
Configuration to access parameters of MicroPdf417.
Definition: micro_pdf417.hpp:17
static std::unique_ptr< MicroPdf417 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: micro_pdf417.hpp:60
Configuration to access parameters of MsiPlessey.
Definition: msi_plessey.hpp:18
static std::unique_ptr< MsiPlessey > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: msi_plessey.hpp:59
Configuration to access parameters of Pdf417.
Definition: pdf417.hpp:17
static std::unique_ptr< Pdf417 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: pdf417.hpp:179
Configuration to access parameters of PharmaCode.
Definition: pharma_code.hpp:18
static std::unique_ptr< PharmaCode > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: pharma_code.hpp:261
Configuration to access parameters of Planet.
Definition: planet.hpp:18
static std::unique_ptr< Planet > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: planet.hpp:61
Configuration to access parameters of Postnet.
Definition: postnet.hpp:17
static std::unique_ptr< Postnet > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: postnet.hpp:60
Configuration to access parameters of QrGrading.
Definition: qr_grading.hpp:17
static std::unique_ptr< QrGrading > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: qr_grading.hpp:107
Configuration to access parameters of Qr.
Definition: qr.hpp:18
static std::unique_ptr< Qr > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: qr.hpp:181
Contains a map of configurations for all active barcode types.
Definition: reader_config.hpp:63
int OmniDirectionalReadoutStripeCount() const noexcept
Get the absolute number of profile lines.
Definition: reader_config.hpp:335
int TimeLimit() const noexcept
This function returns the maximum evaluation time for the decoding of a barcode.
Definition: reader_config.hpp:405
void Flush()
Write all parameters to the handle.
Definition: reader_config.hpp:142
bool CheckCodePosition() const noexcept
This function returns the parameter for the Code Position Check.
Definition: reader_config.hpp:370
std::shared_ptr< TConfig > Configuration()
Returns an existing configuration in the object.
Definition: reader_config.hpp:156
void SetTimeLimit(int timeLimit)
This function sets the maximum evaluation time for the decoding of a barcode.
Definition: reader_config.hpp:389
static std::unique_ptr< ReaderConfig > FromHandle(HandleGuard< ReaderConfig > &&guard)
Creates reader config from a classic API handle.
Definition: reader_config.hpp:95
int ReadoutStripeDistance() const noexcept
Get the distance between lines in pixel.
Definition: reader_config.hpp:263
void RemoveConfiguration()
Removes a configuration from map.
Definition: reader_config.hpp:205
int OmniDirectionalReadoutAngleCount() const noexcept
Set the absolute number of profile rotations.
Definition: reader_config.hpp:299
void SetReadoutMode(Readout readoutMode)
Set the the readout mode.
Definition: reader_config.hpp:220
static std::unique_ptr< ReaderConfig > Load(const Cvb::String &fileName)
Reads the configuration data from file.
Definition: reader_config.hpp:109
void SetReadoutStripeDistance(int range)
Set the distance between lines in pixel.
Definition: reader_config.hpp:244
void SetOmniDirectionalReadoutStripeCount(int numStripe)
Set the absolute number of profile lines.
Definition: reader_config.hpp:316
void SetCheckCodePosition(bool checkPosition)
This function sets the parameter for the Code Position Check.
Definition: reader_config.hpp:353
Readout ReadoutMode() const noexcept
Access the readout mode.
Definition: reader_config.hpp:231
void * Handle() const noexcept
Returns C-API style handle to the reader config.
Definition: reader_config.hpp:80
bool ContainsSymbology(Symbology symbology) const
Check if the object contains the given symbology.
Definition: reader_config.hpp:419
std::shared_ptr< TConfig > CreateConfiguration()
Creates a new configuration for the object.
Definition: reader_config.hpp:174
void Save(Cvb::String fileName)
Writes the data of the configuration to file.
Definition: reader_config.hpp:128
void SetOmniDirectionalReadoutAngleCount(int numAngle)
Set the absolute number of profile rotations.
Definition: reader_config.hpp:280
Configuration to access parameters of SonyCode.
Definition: sony_code.hpp:18
static std::unique_ptr< SonyCode > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: sony_code.hpp:60
Configuration to access parameters of UpcA.
Definition: upc_a.hpp:18
static std::unique_ptr< UpcA > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: upc_a.hpp:30
Configuration to access parameters of UpcE.
Definition: upc_e.hpp:17
static std::unique_ptr< UpcE > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: upc_e.hpp:28
Readout
Available readout modes.
Definition: barcode.hpp:72
@ Omnidirectional
Read a barcode no matter what the orientation of the bars is.
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ Code128
Code 128 Barcode.
@ SonyCode
SonyCode Barcode.
@ DataMatrixGrading
DataMatrix grading.
@ FourStateUsps
Four State USPS Barcode.
@ Codabar
Codabar Barcode.
@ FourStateRoyalMail
Four State Royal Mail Barcode.
@ FourStateKix
Four State KIX Barcode.
@ BarcodeGrading
1D Barcode grading
@ FourStateAustralian
Four State Australian Barcode.
@ Pdf417
PDF417 Matrix Code.
@ Interleaved2of5
2 of 5 Interleaved Barcode
@ PharmaCode
PharmaCode Barcode.
@ Postnet
Postnet Barcode.
@ MicroPdf417
Micro PDF417 Matrix Code.
@ MsiPlessey
MSI Plessey Barcode.
@ QrGrading
QR code grading.
@ DataMatrix
Data Matrix Code.
@ Discrete2of5
2 of 5 Discrete Barcode
ReaderInitialization
Possible ways to initialize a Barcode reader.
Definition: barcode.hpp:88
@ ReadAll
Initialize the reader to read all codes.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24