ZXing无法解析某些二维码的问题分析 - A barcode was not found in this image 问题定位

博客探讨了ZXing在解析高分辨率图片时遇到的问题,分析了二维码定位点搜索、图片灰度转化和二值化的步骤。问题在于ZXHybridBinarizer的二值化过程。提出了增大分块大小、使用ZXGlobalHistogramBinarizer或切换到CIDector作为解决方案,并比较了解析时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用ZXingObjc 存在无法解析某些二维码的bug

一、问题描述

NtQRCode对MA68的部分分享图片中的二维码无法解析

示例:

 

一般是对一些分辨率比较高的图片才存在该问题

按照ZXing的示例代码,接口调用方法如下:

UIImage *image = [指定图片的UIImage对象];
ZXLuminanceSource *source = [[ZXCGImageLuminanceSource alloc] initWithCGImage:image.CGImage];
ZXBinaryBitmap *bitmap = [ZXBinaryBitmap binaryBitmapWithBinarizer:[ZXHybridBinarizer binarizerWithSource:source]];
NSError *error = nil;
[hints addPossibleFormat:kBarcodeFormatQRCode];
ZXMultiFormatReader *reader = [ZXMultiFormatReader reader];
ZXResult *result = [reader decode:bitmap hints:nil error:&error];

返回的result中对应的内容为空,error不为空

返回Error内容如下:
Error=Error Domain=ZXErrorDomain Code=1002 "A barcode was not found in this image" UserInfo={NSLocalizedDescription=A barcode was not found in this image}

这个问题在网上也可以看到其他人上报了该问题

github上ZXingObjC的issue
https://github.com/TheLevelUp/ZXingObjC/issues/245

"再见ZXing 使用系统原生代码处理QRCode
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值