在 ZXing 生成的 QR 码上删除 margin/border space 并将 ErrorCorrectionLevel 设置为 'H'?
remove margin/border space and set ErrorCorrectionLevel to 'H' on QR Codes generated by ZXing?
我想使用 ZXing 生成没有 margin/border space 和 ErrorCreationLevel.H
的二维码,如下所示:
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(com.google.zxing.EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(com.google.zxing.EncodeHintType.MARGIN, 0);
QRCodeWriter writer = new QRCodeWriter();
writer.encode("rasool", BarcodeFormat.QR_CODE, 200, 200, hints);
通过这种方式,生成的QR码包含默认的margin/border space并且可以轻松扫描,但我预计它不应该有任何margin/border space.
而当我评论ErrorCreationLevel
相关的行时,生成的QR码没有任何margin/border space,但不能用智能手机和扫描软件扫描。
我使用的是 ZXing 的 3.4.0 版本。
我该如何解决这个问题?
您扫描的困难无疑与参考解码算法要求静区 ("margin") 保持完整这一事实有关,因此扫描仪无法检测、构建和二值化符号。
纠错级别有助于从二值化符号中恢复 missing/damaged 信息,但如果没有静区,您甚至可能无法在解码过程中走到这一步。
我想使用 ZXing 生成没有 margin/border space 和 ErrorCreationLevel.H
的二维码,如下所示:
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(com.google.zxing.EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(com.google.zxing.EncodeHintType.MARGIN, 0);
QRCodeWriter writer = new QRCodeWriter();
writer.encode("rasool", BarcodeFormat.QR_CODE, 200, 200, hints);
通过这种方式,生成的QR码包含默认的margin/border space并且可以轻松扫描,但我预计它不应该有任何margin/border space.
而当我评论ErrorCreationLevel
相关的行时,生成的QR码没有任何margin/border space,但不能用智能手机和扫描软件扫描。
我使用的是 ZXing 的 3.4.0 版本。
我该如何解决这个问题?
您扫描的困难无疑与参考解码算法要求静区 ("margin") 保持完整这一事实有关,因此扫描仪无法检测、构建和二值化符号。
纠错级别有助于从二值化符号中恢复 missing/damaged 信息,但如果没有静区,您甚至可能无法在解码过程中走到这一步。