【精选】Zbar的安装及环境配置(环境:VS2022、64位Win10、OpenCV3.6.0)_该用户没有设置昵称的博客-CSDN博客按着这篇教程配置属性一步步下来,出现LINK : fatal error LNK1104: 无法打开文件“libzbar64-0.lib报错,虽然自己用的是vs2022,里面的zbar64包是2013编译的,但是感觉应该没事。
解决方法是在在常规中的 附加库目录 里添加zbar的lib就行了!
或者在VC++目录下的 库目录 添加zbar文件中的lib也行
两者都试过了都行,不知道啥区别,反正能跑起来就行!
最后再附上一点用zbar识别QR码的代码
zbar::ImageScanner scanner;
scanner.set_config(zbar::ZBAR_NONE, zbar::ZBAR_CFG_ENABLE, 1);
int width = imgGray.cols;
int height = imgGray.rows;
uchar* raw = (uchar*)imgGray.data;
zbar::Image imageZbar(width, height, "Y800", raw, width * height);
int n = scanner.scan(imageZbar);
if (n > 0)
{
for (zbar::Image::SymbolIterator symbol = imageZbar.symbol_begin();
symbol != imageZbar.symbol_end(); ++symbol) {
string content = symbol->get_data();
cout << "symbol " << content.c_str() << endl;
cout << symbol->get_location_size() << endl;
vector<Point> points;
for (int i = 0; i < symbol->get_location_size(); i++) {
points.push_back(Point(symbol->get_location_x(i), symbol->get_location_y(i)));
}
line(img, points[0], points[1], Scalar(0, 255, 0), 2);
line(img, points[1], points[2], Scalar(0, 255, 0), 2);
line(img, points[2], points[3], Scalar(0, 255, 0), 2);
line(img, points[3], points[0], Scalar(0, 255, 0), 2);
}
}