简体   繁体   English

使用Color Invert QR码进行扫描在带有ZXing的Android中效果不佳

[英]Scan with Color Invert QR code doesn't work well in Android with ZXing

I want to scan scan QR with ZXing library and after hours of research, I find this library and it works like a charm. 我想使用ZXing库进行扫描QR扫描,经过数小时的研究,我找到了该库,它的工作原理很吸引人。 https://libraries.io/github/journeyapps/zxing-android-embedded https://libraries.io/github/journeyapps/zxing-android-embedded

It also reads inverted qr code well, but doesn't read this qr code. 它也能很好地读取反面的二维码,但不会读取该二维码。 http://prnt.sc/dijmc8 http://prnt.sc/dijmc8

I'm not sure why it doesn't read only this qr code. 我不确定为什么它不只读取这个二维码。

Is there anybody who can read qr code with app which is coded with ZXing library(I can read this qr code well with iOS)? 有没有人可以使用ZXing库编码的应用程序读取二维码(我可以在iOS上很好地读取此二维码)? Thanks. 谢谢。

I face same issue after change color for it works for me. 更改颜色后,我会遇到同样的问题,因为它对我有用。 If possible then can you change the color for QR code and then try to read QR code. 如果可能的话,您可以更改QR码的颜色,然后尝试读取QR码。 color to set, Background as White color and QR Code as Black Color. 颜色设置,背景为白色,QR码为黑色。

After trying everything available on the internet, I found this solution- 在尝试了互联网上的所有可用功能之后,我发现了该解决方案-

In your onPreviewFrame(byte[] data, Camera camera) function, add the below code. 在您的onPreviewFrame(byte[] data, Camera camera)函数中,添加以下代码。

toInvert = !toInvert;

if (toInvert == true) {

for (int i = 0; i < data.length; i++) {

data[i] = (byte) (255 - data[i]);

}

}

Also, initialize the Boolean variable toInvert as either true or false in your class scope. 同样,在类范围内将Boolean变量toInvert初始化为true或false。

This addition to your code will scan the image with normal scanning as well as inverted scanning and onPreviewFrame function will return the result as soon as it finds it. 添加到您的代码后,将使用普通扫描和反向扫描来扫描图像,并且onPreviewFrame函数将在找到结果后立即返回结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM