【发布时间】:2016-03-24 21:45:40
【问题描述】:
首先,我通读了如何在 Java 中使用 Zxing 的所有主题,但总是因为缺少 com.google.zxing.client.j2se.* 出现错误(我在 eclipse 中加载了 zxing core-3.2.1.jar并且所有其他 zxing 包都可以工作,除非 j2se) 或刚刚找到用于创建 qr 图像的解决方案...
我的目标是编写一个获取图像文件的方法,在该图像中找到二维码,解码二维码并返回字符串,基本上应该如下所示:
import com.google.zxing.*;
public class QRCode {
/*
* ...
*/
public String getDecodedString(SomeStandardImageType photo){
// detect the qr code in a photo
// create qr image from detected area in photo
// decode the new created qr image and return the string
return "This is the decoded dataString from the qr code in the photo";
}
}
总结一下方法应该得到如下图片文件
并且应该返回 url 或者如果失败只是 ""。
代码应该兼容Zxing 3.2.1。
编辑:问题解决了。对于对此感兴趣的其他人,我想说将外部 jars core-3.2.1.jar 和 javase-3.2.1.jar 添加到外部 jars 中很重要。我的答案在没有后者的情况下有效,但取决于 android 图像库。
【问题讨论】:
-
你的问题是什么?
-
问题是如何让算法与 Zxing 3.2.1 一起工作;另一个方向在这里显示:crunchify.com/java-simple-qr-code-generator-example