我正在尝试使用ZBar库(zbar.sourceforge.net)和opencv来查找二维码。
下面是我的代码:
string findIDIncircle(Mat img, double* angle)
{
ImageScanner scanner;
zbar_image_scanner_set_config(scanner, ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
int width = img.cols;
int height = img.rows;
uchar *raw = (uchar *)img.data;
Image image(width, height, "Y800", raw, width * height);
scanner.scan(image);
SymbolSet symbols = image.get_symbols();
for(Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); symbol++)
{
string data = symbol->get_data();
vector<Point> vp;
int n = symbol->get_location_size();
for(int i=0;i<n;i++)
{
vp.push_back(Point(symbol->get_location_x(i),symbol->get_location_y(i)));
}
RotatedRect r = minAreaRect(vp);
*angle = r.angle;
return data;
}
return "";
}但是代码什么也找不到。我在img上使用imwrite检查了参数,图像是正确且非常清晰的(它是用http://www.qrcode-generator.de/生成的),谁能告诉我,问题出在哪里?
发布于 2015-12-23 20:22:57
好吧,我自己解决了它,不得不把它转换成灰度:
Mat gray;
cvtColor(img,gray,CV_BGR2GRAY);
uchar *raw = (uchar *)gray.data;https://stackoverflow.com/questions/34435220
复制相似问题