38 itsScanner->set_config(zbar::ZBAR_NONE, zbar::ZBAR_CFG_ENABLE, 0);
42 for (std::string
const & v : vec)
45 itsScanner->set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_ENABLE, 1);
46 itsScanner->set_config(zbar::ZBAR_EAN2, zbar::ZBAR_CFG_ENABLE, 1);
47 itsScanner->set_config(zbar::ZBAR_EAN5, zbar::ZBAR_CFG_ENABLE, 1);
48 itsScanner->set_config(zbar::ZBAR_EAN8, zbar::ZBAR_CFG_ENABLE, 1);
49 itsScanner->set_config(zbar::ZBAR_EAN13, zbar::ZBAR_CFG_ENABLE, 1);
50 itsScanner->set_config(zbar::ZBAR_UPCE, zbar::ZBAR_CFG_ENABLE, 1);
51 itsScanner->set_config(zbar::ZBAR_UPCA, zbar::ZBAR_CFG_ENABLE, 1);
52 itsScanner->set_config(zbar::ZBAR_ISBN10, zbar::ZBAR_CFG_ENABLE, 1);
53 itsScanner->set_config(zbar::ZBAR_ISBN13, zbar::ZBAR_CFG_ENABLE, 1);
54 itsScanner->set_config(zbar::ZBAR_COMPOSITE, zbar::ZBAR_CFG_ENABLE, 1);
55 itsScanner->set_config(zbar::ZBAR_I25, zbar::ZBAR_CFG_ENABLE, 1);
56 itsScanner->set_config(zbar::ZBAR_DATABAR, zbar::ZBAR_CFG_ENABLE, 1);
57 itsScanner->set_config(zbar::ZBAR_DATABAR_EXP, zbar::ZBAR_CFG_ENABLE, 1);
58 itsScanner->set_config(zbar::ZBAR_CODABAR, zbar::ZBAR_CFG_ENABLE, 1);
59 itsScanner->set_config(zbar::ZBAR_CODE39, zbar::ZBAR_CFG_ENABLE, 1);
60 itsScanner->set_config(zbar::ZBAR_PDF417, zbar::ZBAR_CFG_ENABLE, 1);
61 itsScanner->set_config(zbar::ZBAR_CODE93, zbar::ZBAR_CFG_ENABLE, 1);
62 itsScanner->set_config(zbar::ZBAR_CODE128, zbar::ZBAR_CFG_ENABLE, 1);
64 else if (v ==
"QRCODE")
itsScanner->set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_ENABLE, 1);
65 else if (v ==
"EAN2")
itsScanner->set_config(zbar::ZBAR_EAN2, zbar::ZBAR_CFG_ENABLE, 1);
66 else if (v ==
"EAN5")
itsScanner->set_config(zbar::ZBAR_EAN5, zbar::ZBAR_CFG_ENABLE, 1);
67 else if (v ==
"EAN8")
itsScanner->set_config(zbar::ZBAR_EAN8, zbar::ZBAR_CFG_ENABLE, 1);
68 else if (v ==
"EAN13")
itsScanner->set_config(zbar::ZBAR_EAN13, zbar::ZBAR_CFG_ENABLE, 1);
69 else if (v ==
"UPCE")
itsScanner->set_config(zbar::ZBAR_UPCE, zbar::ZBAR_CFG_ENABLE, 1);
70 else if (v ==
"UPCA")
itsScanner->set_config(zbar::ZBAR_UPCA, zbar::ZBAR_CFG_ENABLE, 1);
71 else if (v ==
"ISBN10")
73 itsScanner->set_config(zbar::ZBAR_EAN13, zbar::ZBAR_CFG_ENABLE, 1);
74 itsScanner->set_config(zbar::ZBAR_ISBN10, zbar::ZBAR_CFG_ENABLE, 1);
76 else if (v ==
"ISBN13")
78 itsScanner->set_config(zbar::ZBAR_EAN13, zbar::ZBAR_CFG_ENABLE, 1);
79 itsScanner->set_config(zbar::ZBAR_ISBN13, zbar::ZBAR_CFG_ENABLE, 1);
81 else if (v ==
"COMPOSITE")
itsScanner->set_config(zbar::ZBAR_COMPOSITE, zbar::ZBAR_CFG_ENABLE, 1);
82 else if (v ==
"I25")
itsScanner->set_config(zbar::ZBAR_I25, zbar::ZBAR_CFG_ENABLE, 1);
83 else if (v ==
"DATABAR")
itsScanner->set_config(zbar::ZBAR_DATABAR, zbar::ZBAR_CFG_ENABLE, 1);
84 else if (v ==
"DATABAREXP")
itsScanner->set_config(zbar::ZBAR_DATABAR_EXP, zbar::ZBAR_CFG_ENABLE, 1);
85 else if (v ==
"CODABAR")
itsScanner->set_config(zbar::ZBAR_CODABAR, zbar::ZBAR_CFG_ENABLE, 1);
86 else if (v ==
"CODE39")
itsScanner->set_config(zbar::ZBAR_CODE39, zbar::ZBAR_CFG_ENABLE, 1);
87 else if (v ==
"PDF417")
itsScanner->set_config(zbar::ZBAR_PDF417, zbar::ZBAR_CFG_ENABLE, 1);
88 else if (v ==
"CODE93")
itsScanner->set_config(zbar::ZBAR_CODE93, zbar::ZBAR_CFG_ENABLE, 1);
89 else if (v ==
"CODE128")
itsScanner->set_config(zbar::ZBAR_CODE128, zbar::ZBAR_CFG_ENABLE, 1);
90 else LFATAL(
"Invalid symbol type [" << v <<
']');
149 int w,
int h,
size_t nshow)
154 std::string txt; std::vector<std::string> qdata;
155 for (zbar::Image::SymbolIterator symbol = zgray.symbol_begin(); symbol != zgray.symbol_end(); ++symbol)
158 txt +=
' ' + symbol->get_type_name();
159 qdata.push_back(std::string(symbol->get_type_name()) +
": " + symbol->get_data());
163 if (symbol->get_type() == zbar::ZBAR_QRCODE)
165 zbar::Symbol::Point pp(-1000000, -1000000);
166 for (zbar::Symbol::PointIterator pitr = symbol->point_begin(); pitr != symbol->point_end(); ++pitr)
168 zbar::Symbol::Point p(*pitr);
172 if (pp.x != -1000000)
174 zbar::Symbol::Point p = *(symbol->point_begin());
180 int tlx = w, tly =
h, brx = -1, bry = -1;
181 for (zbar::Symbol::PointIterator pitr = symbol->point_begin(); pitr != symbol->point_end(); ++pitr)
183 zbar::Symbol::Point p(*pitr);
184 if (p.x < tlx) tlx = p.x;
185 if (p.x > brx) brx = p.x;
186 if (p.y < tly) tly = p.y;
187 if (p.y > bry) bry = p.y;
189 tlx = std::min(
int(w)-1, std::max(0, tlx));
190 brx = std::min(
int(w)-1, std::max(0, brx));
191 tly = std::min(
int(
h)-1, std::max(0, tly));
192 bry = std::min(
int(
h)-1, std::max(0, bry));
202 txt =
"Found " + std::to_string(qdata.size()) +
" symbols:" + txt;
204 for (
size_t i = 0; i < std::min(qdata.size(), nshow - 1); ++i)
213 ImU32
const col = ImColor(255, 192, 64, 255);
216 std::vector<std::string> qdata;
217 for (zbar::Image::SymbolIterator symbol = zgray.symbol_begin(); symbol != zgray.symbol_end(); ++symbol)
220 qdata.push_back(
" - " + std::string(symbol->get_type_name()) +
": " + symbol->get_data());
224 if (symbol->get_type() == zbar::ZBAR_QRCODE)
226 std::vector<cv::Point2f> points;
227 for (zbar::Symbol::PointIterator pitr = symbol->point_begin(); pitr != symbol->point_end(); ++pitr)
229 zbar::Symbol::Point p(*pitr);
230 points.emplace_back(cv::Point2f(p.x, p.y));
236 int tlx = w, tly =
h, brx = -1, bry = -1;
237 for (zbar::Symbol::PointIterator pitr = symbol->point_begin(); pitr != symbol->point_end(); ++pitr)
239 zbar::Symbol::Point p(*pitr);
240 if (p.x < tlx) tlx = p.x;
241 if (p.x > brx) brx = p.x;
242 if (p.y < tly) tly = p.y;
243 if (p.y > bry) bry = p.y;
245 tlx = std::min(
int(w)-1, std::max(0, tlx));
246 brx = std::min(
int(w)-1, std::max(0, brx));
247 tly = std::min(
int(
h)-1, std::max(0, tly));
248 bry = std::min(
int(
h)-1, std::max(0, bry));
249 helper.
drawRect(tlx, tly, brx, bry, col,
true);
254 helper.
itext(
"Detected " + std::to_string(qdata.size()) +
" QRcode/Barcode symbols.");
255 for (
size_t i = 0; i < qdata.size(); ++i) helper.
itext(qdata[i]);