【发布时间】:2020-07-30 13:19:22
【问题描述】:
我需要在相机捕捉时捕捉和读取二维码,所有这些都在 JSF 应用程序中。
我已经阅读了照片中的二维码,但现在我必须让它“活着”。
有人有什么建议吗?
我正在尝试使用 PrimeFaces 的 p:photoCam。
这是方法,使用Zxing读取二维码:
/**
*
* @param filePath
* @param charset
* @param hintMap
*
* @return Qr Code value
*
* @throws FileNotFoundException
* @throws IOException
* @throws NotFoundException
*/
public static String readQRCode(String filePath, String charset, Map hintMap)
throws FileNotFoundException, IOException, NotFoundException {
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(
new BufferedImageLuminanceSource(
ImageIO.read(new FileInputStream(filePath)))));
Result qrCodeResult = new MultiFormatReader().decode(binaryBitmap);
return qrCodeResult.getText();
}
}
【问题讨论】:
-
我在这里没有看到任何与 JSF 或 PrimeFaces 相关的代码/尝试
-
使用 PrimeFaces 组件尚无法实现。见github.com/primefaces-extensions/…
-
我明白了!!!现在我的问题是用 chrome 或 firefox 打开相机,使用 primefaces 6.1.RC2,但我知道这个版本的 p:photoCam 并不完美。如何仅更新此组件并保留我的 Primefaces 版本?
-
您为什么要继续使用候选版本?我建议在 PrimeFaces 9 发布的那一刻升级到它。举个例子,jQuery 中有一个 XSS 漏洞,在 9 中修复。forum.primefaces.org/viewtopic.php?f=3&t=63144
标签: java jsf primefaces camera qr-code