read_result.hpp
1 #pragma once
2 
3 #include "../../_cexports/c_barcode.h"
4 #include "../../global.hpp"
5 #include "cvb/string.hpp"
6 #include "cvb/point_2d.hpp"
7 #include "../barcode.hpp"
8 
9 
10 namespace Cvb
11 {
12  CVB_BEGIN_INLINE_NS
13 
14  namespace Barcode
15  {
16 
18 
22  class ReadResult
23  {
24  public:
25 
27 
30  ReadResult(CExports::CVC_BC_INFO& handle)
31  : handle_(handle)
32  {
33  }
34 
35  virtual ~ReadResult() {}
36 
37 
39 
43  virtual Cvb::String Text() const noexcept
44  {
45  return text_;
46  }
47 
48 
50 
54  int CharactersRead() const
55  {
56  return static_cast<int>(handle_.char_read);
57  }
58 
59 
61 
65  int DecodeTime() const
66  {
67  return static_cast<int>(handle_.decoding_time);
68  }
69 
70 
72 
77  {
78  if ((handle_.p3_x == 0) && (handle_.p3_y == 0)
79  && (handle_.p4_x == 0) && (handle_.p4_y == 0))
81  Cvb::Point2D<double>(handle_.p1_x, handle_.p1_y),
82  Cvb::Point2D<double>(handle_.p2_x, handle_.p2_y)
83  };
84  else
86  Cvb::Point2D<double>(handle_.p1_x, handle_.p1_y),
87  Cvb::Point2D<double>(handle_.p2_x, handle_.p2_y),
88  Cvb::Point2D<double>(handle_.p3_x, handle_.p3_y),
89  Cvb::Point2D<double>(handle_.p4_x, handle_.p4_y)
90  };
91  }
92 
93 
95 
99  int NumWords() const
100  {
101  return static_cast<int>(handle_.num_digits);
102  }
103 
104 
106 
110  double Resolution() const
111  {
112  return static_cast<double>(handle_.resolution) / 10.0;
113  }
114 
115 
117 
122  {
123  return static_cast<DecodeResult>(handle_.decoding_result);
124  }
125 
126 
127 
129 
133  Symbology Type() const
134  {
135  return static_cast<Symbology>(handle_.type);
136  }
137 
138 
139 
140  protected:
141  CExports::CVC_BC_INFO handle_;
142  Cvb::String text_;
143 
144  friend class Reader;
145  };
146 
147  }
148 
149  CVB_END_INLINE_NS
150 }
int CharactersRead() const
The return value contains the number of characters in the read barcode.
Definition: read_result.hpp:54
Symbology Type() const
Symbology of the decoded result.
Definition: read_result.hpp:133
The key class for reading barcodes.
Definition: reader.hpp:31
Base class for reading decoded barcode results.
Definition: read_result.hpp:22
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:96
STL class.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
int NumWords() const
Contains the number of code words composing the read barcode.
Definition: read_result.hpp:99
STL class.
ReadResult(CExports::CVC_BC_INFO &handle)
Constructor to initialize object from info struct.
Definition: read_result.hpp:30
std::vector< Cvb::Point2D< double > > Location() const
Location of the barcode inside the image.
Definition: read_result.hpp:76
DecodeResult
Possible barcode reading results.
Definition: barcode.hpp:442
double Resolution() const
The resolution specifies the smallest width unit in the code in multiples of a 10th of a pixel.
Definition: read_result.hpp:110
virtual Cvb::String Text() const noexcept
The text content of the barcode.
Definition: read_result.hpp:43
int DecodeTime() const
The return value specifies the time consumed for decoding in units of ms.
Definition: read_result.hpp:65
DecodeResult Result() const
Decoding result.
Definition: read_result.hpp:121