0
我有一個代碼來解碼圖像文件並解碼它的qrcode。我正在使用zxing庫。但我怎麼能讓這個從網絡攝像頭捕捉qrcode並解碼它。我需要做什麼改變?任何一個人都可以一步一步解釋這一點。如何使用zxing通過網絡攝像頭解碼qrcode
這裏是代碼:
public class QrCodeDecoder
{
public String decode(File imageFile)
{
BufferedImage image;
try
{
image = ImageIO.read(imageFile);
}
catch (IOException e1)
{
return "io outch";
}
// creating luminance source
LuminanceSource lumSource = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(lumSource));
// barcode decoding
QRCodeReader reader = new QRCodeReader();
Result result = null;
try {
result = reader.decode(bitmap);
}
catch (ReaderException e)
{
return "reader error";
}
return result.getText();
}
}