2012-05-19 7 views
0

Я хочу, чтобы захватить изображение с помощью веб-камеры в Java на убунту 11,10JMF java.util.NoSuchElementException не видит веб-камеру

  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 в справочные библиотеки в моем проекте.

Моя веб-камера правильно работает.

Что я должен делать, чтобы увидеть веб-камеру?

Спасибо за помощь

ответ

0

Пожалуйста, проверьте Вектор 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() 

deviceList пуст. Вызывается метод isEmpty() перед вызовом метода firstElement(). Если isEmpty() возвращает true, вы не можете вызвать метод firstElement().

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

 Смежные вопросы

  • Нет связанных вопросов^_^