在zbar二维码解码器中使用opencv代替imagemagick

发布于 2025-01-03 17:41:17 字数 518 浏览 4 评论 0原文

我正在使用 Zbar api 编写一个二维码解码器。我正在使用 Windows 预建库。我使用以下代码将图像加载到 ZBar

IplImage *src=cvLoadImage("image.png",CV_LOAD_IMAGE_GRAYSCALE);
ImageScanner scanner;
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);  
int width = src->width;
int height = src->height;   
uchar* raw = (uchar *)(src->imageData);
Image image(width, height, "Y800", raw, width * height);
int n = scanner.scan(image);

但无法解码图像。我是否使用正确的方法使用 opencv 读取图像数据? 。当我只测试一张图像时,所有其他图像均已解码并失败。但当我使用 zbarimg 命令行选项时它运行良好

I am writing a qr code decoder using Zbar api. I am using windows pre built libraries . I used the following code to load the image to ZBar

IplImage *src=cvLoadImage("image.png",CV_LOAD_IMAGE_GRAYSCALE);
ImageScanner scanner;
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);  
int width = src->width;
int height = src->height;   
uchar* raw = (uchar *)(src->imageData);
Image image(width, height, "Y800", raw, width * height);
int n = scanner.scan(image);

But it failed to decode the image. Am I using the correct way to read image data using opencv ? . When I tested only one image decoded and failed for all others . But it is working well when I used the zbarimg command line option

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文