android - QR 码未在图像中检测到 BarcodeDetector
问题描述
我已经使用 BarcodeDetector 从图像中实现 QR 码检测
BarcodeDetector detector = new BarcodeDetector.Builder(getApplicationContext())
.setBarcodeFormats(/*Barcode.DATA_MATRIX | Barcode.QR_CODE|*/Barcode.QR_CODE)
.build();
if (detector.isOperational()) {
Log.e("QR_READ", "Could not set up the detector!");
Frame frame = new Frame.Builder().setBitmap(pageBitmap).build();
QRCodeList = detector.detect(frame);
}
这里 QRCodeList 是空的,但该图像中有 QR 码。但是有些图像正在使用代码,但有些图像没有检测到,但是我在网上检查的那些图像,那些正在使用的图像。为什么那个代码没有检测到二维码?
解决方案
也许这只是您正在扫描的那些二维码的问题。尝试使用在线 QRCode 生成器并检查它是否适用于您将生成的每个 QRCode。
此外,您可以打印扫描返回的原始值。这是 Kotlin 但您可以将其转换为 Java 。像这样的东西:
val rawScanValue: String = QRCodeList.valueAt(0).rawValue
// or toast or whatever
Log.d('RAWVALUE',rawScanValue)
推荐阅读
- python - 是否可以通过溢出从 div 中的 div 获取数据:隐藏在 python 的请求中?
- java - 从 Groovy 到 Groovy DSL 的 PackageFatJar 任务
- sql - 如何将 Sum 用于字符串函数?
- .net-4.5 - 如何填充 System.Environment?
- python - Python NLP 区分英式英语和美式英语
- python - Python中的简单问题减去数组
- react-native - reactnative package.json 依赖更新
- git - 在 Git GUI 中通过 SSH 从 BitBucket 克隆 repo
- swift - 我如何绘制路线行走(点)
- postgresql - 与其他用户共享 sql 脚本时替换架构名称