6

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

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

不过,我熟悉 ZXing 用于解码条码图像。

我搜索了高低,我强烈怀疑我要查找的库不存在,但值得一问!

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

编辑:或者,如果不存在,您能否指出我在检测到二维码时如何从网络摄像头拍摄快照的正确方向?:)

谢谢

4

3 回答 3

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());
}
于 2012-11-24T12:25:50.140 回答
0

您可以使用 gstreamer 与您的相机进行交互。对于 Windows,它可能又是 gstreamer 或 DirectShow。在这两种情况下,您都需要使用一些特殊的过滤器来捕获数据,在 DirectShow 中它将是 SampleGrabber。我认为 gstreamer 应该提供一些类似的插件。

于 2012-05-06T19:17:50.727 回答
0

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

于 2012-05-06T21:28:03.793 回答