简体   繁体   English

Java中的网络摄像头错误

[英]Webcam in java Errors

I am trying to use my cam in java app but i get some errors here is the my code. 我试图在Java应用程序中使用我的cam,但是这里出现了一些错误,这是我的代码。 its simple someone tells me whats wrong with my code: 它很简单,有人告诉我我的代码有什么问题:

import java.util.Vector;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFrame;
public class Main extends JFrame {

    public Main(){

        super("Jcam");
        try {


        Vector v = CaptureDeviceManager.getDeviceList(null);
        CaptureDeviceInfo cam = null;
        for(int i=0;i<v.size();i++)
        {
            CaptureDeviceInfo dev = (CaptureDeviceInfo) v.elementAt(i);
            if(dev.getName().startsWith("vfw"))
            {
                cam = dev;
                break;
            }
            System.out.println(dev.getName());

        }
        if (cam == null){ System.exit(0); }
        MediaLocator ml = cam.getLocator();
        Player p = Manager.createRealizedPlayer(ml);
        add(p.getVisualComponent());
        p.start();
        } catch (Exception e) {

        }
        setSize(700, 700);
        setVisible(true);
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        new Main();
    }

and here is the log 这是日志

Exception in thread "VFW Request Thread" java.lang.UnsatisfiedLinkError:     JMFSecurityManager: java.lang.UnsatisfiedLinkError: no jmvfw in java.library.path
    at com.sun.media.JMFSecurityManager.loadLibrary(JMFSecurityManager.java:206)
    at com.sun.media.protocol.vfw.VFWCapture.<clinit>(VFWCapture.java:19)
    at com.sun.media.protocol.vfw.VFWSourceStream.doConnect(VFWSourceStream.java:241)
    at com.sun.media.protocol.vfw.VFWSourceStream.run(VFWSourceStream.java:763)
    at java.lang.Thread.run(Unknown Source)

Try downloading and including the platform independent distribution. 尝试下载并包括独立于平台的发行版。 I got the same error when I tried using jmf on windows - but when I switched from using the windows distribution to the platform independent one, it worked. 我在Windows上尝试使用jmf时遇到了相同的错误-但是当我从使用Windows发行版切换到独立于平台的发行版时,它起作用了。

解决了..因为它是64位操作系统..jmf在64位上不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM