Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法识别彩色二维码 #578

Open
deanhaiwei opened this issue Apr 26, 2023 · 6 comments
Open

无法识别彩色二维码 #578

deanhaiwei opened this issue Apr 26, 2023 · 6 comments

Comments

@deanhaiwei
Copy link

No description provided.

@wscjy
Copy link

wscjy commented Apr 26, 2023 via email

@deanhaiwei
Copy link
Author

ZXingView 可更新下

@deanhaiwei
Copy link
Author

rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
if (rawResult == null) {
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source)));
if (rawResult != null) {
BGAQRCodeUtil.d("GlobalHistogramBinarizer 没识别到,HybridBinarizer 能识别到");
}
}

改成
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
if (rawResult == null) {
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source)));
if (rawResult != null) {
BGAQRCodeUtil.d("GlobalHistogramBinarizer 没识别到,HybridBinarizer 能识别到");
}else{
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source.invert())));
}
}

rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source.invert())));加上这个可以识别彩色二维码

@deanhaiwei
Copy link
Author

识别的那段代码有问题!作者有空改下吧!
private Result getRawResult(Binarizer binarizer){
Result rawResult;
try {
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(binarizer));
}catch (Exception e){
rawResult = null;
}
return rawResult;
}

rawResult = getRawResult(new GlobalHistogramBinarizer(source));
if (rawResult == null) {
rawResult = getRawResult(new HybridBinarizer(source));
if (rawResult != null) {
BGAQRCodeUtil.d("GlobalHistogramBinarizer 没识别到,HybridBinarizer 能识别到");
}else {
rawResult = getRawResult(new HybridBinarizer(source.invert()));
}
}


rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
这段代码会报NotFoundException 异常
rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source)));
这段就不生效了改完识别率会提高,还能识别彩色的二维码!

@dingliufan
Copy link

是的,下载源码 按照您这样改就可以,效率还变高了

@wscjy
Copy link

wscjy commented Dec 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants