网络摄像头 - 检测QR码,拍摄快照和解码

chr*_*sby 5 java webcam qr-code snapshot

我目前正在尝试编写一个java程序,以利用内置的笔记本电脑摄像头或外部USB网络摄像头.这有望与PC和Mac兼容.

我想知道是否有人知道可以处理这一切的图书馆?我真的不想重新发明轮子,我不知道从哪里开始1)检测网络摄像头,2)在检测到QR码时拍摄快照.

我熟悉ZXing解码条形码图像.

我一直在寻找高低,我强烈怀疑我寻找的图书馆不存在,但值得一提!

我在这里的第一个问题,所以我希望很清楚!

编辑:或者,如果一个不存在,你可以指出我在检测到QR码时如何从网络摄像头拍摄快照的正确方向吗?:)

谢谢

Bar*_*ryn 6

此示例介绍如何使用Webcam Capture库和ZXing 读取QR代码数据.Webcam Capture兼容32位和64位Windows,Linux和Mac OX.对于Linux,它还支持ARM体系结构.

代码非常简单:

Webcam webcam = Webcam.getDefault(); // non-default (e.g. USB) webcam can be used too
webcam.open();

Result result = null;
BufferedImage image = null;

if (webcam.isOpen()) {
    if ((image = webcam.getImage()) == null) {
        continue;
    }

    LuminanceSource source = new BufferedImageLuminanceSource(image);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    try {
        result = new MultiFormatReader().decode(bitmap);
    } catch (NotFoundException e) {
        // fall thru, it means there is no QR code in image
    }
}

if (result != null) {
    System.out.println("QR code data is: " + result.getText());
}
Run Code Online (Sandbox Code Playgroud)


Sea*_*wen 0

zxing 有一个 Actionscript 端口,这使得它可以通过 Flash 使用,Flash 可以访问网络摄像头。该端口有点旧,不是 100% 完整,但应该可以工作。