FMJ 网络摄像头捕获示例

发布于 2024-08-02 02:23:29 字数 62 浏览 2 评论 0原文

我一直在寻找一段时间,但找不到如何使用 FMJ 捕获网络摄像头流的简单示例。 有任何教程或示例可以帮助我吗?

I've been searching for while now and I can't find a simple example of how to capture a webcam stream with FMJ. Are there any tutorials or examples available which could help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄意 2024-08-09 02:23:29

我使用 FMJ 已经有一段时间了,但我还没有找到很多可以开始的例子。 我要做的是探索 FmjStudio 类,它集成了网络摄像头功能并且非常简单。

对于鲍勃:

你想要的是 FMJ。 FMJ 使用民用数据源实现来将其与 JMF 一起使用。 我建议您去 http://fmj-sf.net/ 下载最新的源代码并探索FmjStudio 也是如此,因为它使用民用来捕获。

对于 theDude:

你是对的,你也可以使用 JMF,但是你用于 JMF 的相同代码很可能适用于 FMJ(也许有 coupla 更改),并且性能会好得多,特别是如果你想要各种不同的网络摄像头与您的软件配合使用。

I have been working with FMJ for a while and I haven't found many examples to start with either. What I would do is to explore the FmjStudio class that has the webcam functionality integrated and its pretty straight forward.

For bob:

What you want is FMJ. FMJ uses an DataSource implementation for civil to use it with JMF. I would recommend you to go to http://fmj-sf.net/ download the latest source and explore FmjStudio aswell since it uses civil to capture.

For theDude:

You are right, you can use JMF aswell but the same code you use for JMF will most likely work with FMJ (maybe with a coupla changes) and the performance will be much better, specially if you want a wide range of different webcams to work with your software.

白云悠悠 2024-08-09 02:23:29

我知道这不是您想听到的,但我已使用 JMF 来完成此任务,并且效果非常好。 网上有足够多的示例可以轻松运行简单的网络摄像头捕获应用程序。 如果您有兴趣,我会发布更多内容。

I know this isn't what you want to hear, but I've used JMF for this task and it works very well. There are enough examples online to get a simple web cam capture app running pretty easily. I'll post more if you're interested.

夕嗳→ 2024-08-09 02:23:29

以下代码将帮助您入门。

GlobalCaptureDevicePlugger.addCaptureDevices(); 
    Vector<CaptureDeviceInfo> audioCapDevList = CaptureDeviceManager.getDeviceList(null);
    if (audioCapDevList.size() != 0) {
        for (int i = 0; i < audioCapDevList.size(); i++) {
            audioCapDevInfo = audioCapDevList.elementAt(i);
            Format[] videoFormats = audioCapDevInfo.getFormats();
            System.out.println(audioCapDevInfo);
            if (audioCapDevInfo.getName().startsWith("vfw:")) { // assume the name of the webcam starts with vfw:
                for (int j = 0; j < videoFormats.length; j++) {
                    if (videoFormats[j] instanceof VideoFormat) {
                        currentFormat = (VideoFormat) videoFormats[i];
                        break;
                    }
                }
                System.out.println(currentFormat);
                if (currentFormat == null) {
                    System.err.println("Search for VideoFormat failed");
                    System.exit(-1);
                }
                audioCapDevLoc = audioCapDevInfo.getLocator();
            }

        }
    }

请确保本机库(civil.dll 和 jdshow.dll)已加载到 JVM 中。 否则,您将收到 java.lang.UnsatisfiedLinkError。 以下代码可能会为您完成这项工作。

    System.setProperty("java.library.path", "D:/fmj-sf/native/win32-x86/");
    Field fieldSysPath;
    try {
        fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
        fieldSysPath.setAccessible(true);
        fieldSysPath.set(null, null);
    } catch (Exception e) {
        e.printStackTrace();
    }

The following code would get you started.

GlobalCaptureDevicePlugger.addCaptureDevices(); 
    Vector<CaptureDeviceInfo> audioCapDevList = CaptureDeviceManager.getDeviceList(null);
    if (audioCapDevList.size() != 0) {
        for (int i = 0; i < audioCapDevList.size(); i++) {
            audioCapDevInfo = audioCapDevList.elementAt(i);
            Format[] videoFormats = audioCapDevInfo.getFormats();
            System.out.println(audioCapDevInfo);
            if (audioCapDevInfo.getName().startsWith("vfw:")) { // assume the name of the webcam starts with vfw:
                for (int j = 0; j < videoFormats.length; j++) {
                    if (videoFormats[j] instanceof VideoFormat) {
                        currentFormat = (VideoFormat) videoFormats[i];
                        break;
                    }
                }
                System.out.println(currentFormat);
                if (currentFormat == null) {
                    System.err.println("Search for VideoFormat failed");
                    System.exit(-1);
                }
                audioCapDevLoc = audioCapDevInfo.getLocator();
            }

        }
    }

Please make sure the native libraries (civil.dll and jdshow.dll) are loaded into the JVM. Otherwise, you would get an java.lang.UnsatisfiedLinkError. The following code may do the job for you.

    System.setProperty("java.library.path", "D:/fmj-sf/native/win32-x86/");
    Field fieldSysPath;
    try {
        fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
        fieldSysPath.setAccessible(true);
        fieldSysPath.set(null, null);
    } catch (Exception e) {
        e.printStackTrace();
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文