【问题标题】:JMF java.util.NoSuchElementException not see my webcamJMF java.util.NoSuchElementException 看不到我的网络摄像头
【发布时间】:2012-05-26 20:12:30
【问题描述】:

我想在 ubuntu 11.10 上使用我的网络摄像头在 Java 中捕获图像

         Vector deviceList = CaptureDeviceManager.getDeviceList( new RGBFormat());
        System.out.println(deviceList.toString());
        //gets the first device in deviceList
        device = (CaptureDeviceInfo) deviceList.firstElement();

我有异常“java.util.NoSuchElementException”

我安装了 jmf-2_1_1e-linux-i586.bin 并在我的项目的参考库中添加了 jmf.jar。

我的网络摄像头工作正常。

看到我的网络摄像头我该怎么办?

感谢您的帮助

【问题讨论】:

    标签: java eclipse webcam capture jmf


    【解决方案1】:

    请检查 Vector API,您可以看到:

    /**
     * Returns the first component (the item at index <tt>0</tt>) of 
     * this vector.
     *
     * @return     the first component of this vector.
     * @exception  NoSuchElementException  if this vector has no components.
     */
    public synchronized Object firstElement()
    

    设备列表为空。您应该在调用 firstElement() 方法之前调用 isEmpty() 方法。如果 isEmpty() 返回 true,则不能调用 firstElement() 方法。

    if(deviceList!=null && !deviceList.isEmpty()){
        device = (CaptureDeviceInfo) deviceList.firstElement();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 2011-12-21
      • 1970-01-01
      • 2013-07-09
      • 1970-01-01
      相关资源
      最近更新 更多