Open GermainChavigny opened 6 years ago
Have you found a solution for this issue? Facing the same issue here Thanks!
CameraSettings settings = new CameraSettings(); settings.setScanInverted(true);
maybe can resolve your problem!
我找到了更好的办法解决该问题。 问题原因:二维码是基于浅色背景,深色图案设计的,所以在识别深色背景,浅色图案时,会难以识别。 解决思路:解析二维码时,先以正常的解析一次,然后再通过算法,将深浅颜色交换重新识别一次。(查阅zxing-android-embedded 源码,发现正是该处理方案) 解决步骤: 1、找到 zxing-android-embedded源码,下载到本地,并作为module引入你的项目。 2、引入之后,由于最新的zxing-android-embedded源码使用的androidx,你需要修改成 v4依赖。 3、修改zxing-android-embedded源码,找到DefaultDecoderFactory.java文件,修改其中的解析方法 我们可以看到,MixedDecoder中正是正反各解析一次。 4、修改完成之后即可正常识别深色背景 浅色图案的二维码了。但是由于我们这边使用的是cordova框架,每次重新构建时,gradle.properties都会被重置,所以我们将修改好的zxing-android-embedded项目打包成aar文件,并将打包好的aar引入到app项目的libs下。 5、修改cordova-plugin-qrscanner下的xxx-qrscanner.gradle配置文件, ` repositories{ jcenter() flatDir{ dirs 'libs' } }
dependencies { implementation (name: 'zxing-android-embedded', ext: 'aar') implementation 'com.google.zxing:core:3.4.0' } ` 大功告成。目前我就是采用的该方案,如果有更好的方案,欢迎与我讨论。
I have implemented the required changes to enable scanning white on black QR code on Android. The changes are:
zxing-android-embedded:4.3.0
You can install from my forked version of the original repository https://github.com/ryaa/cordova-plugin-qrscanner
Please note that for the latest version zxing-android-embedded:4.3.0
Android SDK 24+ is required (see https://github.com/journeyapps/zxing-android-embedded#zxing-android-embedded)
The plugin works really well on IOS, but on Android it seem that only the black on white QR Code are recognized, and not the white on black.
Works on IOS and Android, text type ("3464E726"), black on white : https://www.unitag.io/qreator/generate?crs=xnjFkEn%252FP85fCPDXJ%252FXXKnPnKU%252FtWVh9E7ei8Ex%252BR4XsTvus59MiRl4OtJ5Y%252F3aRXopA7Qn4wJ6m3qLfsP4IWv39ocSd3mMczmj1AuyiW6IsnzP3lR5so0CxdVH10KxUVPjNjk7PNdS451TzJElqMA%253D%253D&crd=mXKe51B3LcpJnGj6pepi6dcIhscPmUGdUGZHTQubkC08jItbKk4p5g9V1ZnlQx%252Fka8VPyY6bBSj14B1fT1yw5w%253D%253D
Works on IOS, doesn't works on Android, text type ("3464E726"), white on black : https://www.unitag.io/qreator/generate?crs=xnjFkEn%252FP85fCPDXJ%252FXXKnPnKU%252FtWVh9E7ei8Ex%252BR4XsTvus59MiRl4OtJ5Y%252F3aRXopA7Qn4wJ6m3qLfsP4IWuMZkF12fqmkoTiUveDOfl5nEQtdZ%252Fv7Ox2YGWxkySQqPWDhCivfWWNUUcxDFevrfA%253D%253D&crd=mXKe51B3LcpJnGj6pepi6dcIhscPmUGdUGZHTQubkC08jItbKk4p5g9V1ZnlQx%252Fka8VPyY6bBSj14B1fT1yw5w%253D%253D
Is there any way to fix this ?
Thanks