I want to capture image using my webcam in Java on ubuntu 11.10
Vector deviceList = CaptureDeviceManager.getDeviceList( new RGBFormat());
System.out.println(deviceList.toString());
//gets the first device in deviceList
device = (CaptureDeviceInfo) deviceList.firstElement();
I have exception "java.util.NoSuchElementException"
I installed jmf-2_1_1e-linux-i586.bin and i added jmf.jar in reference libraries in my project.
My webcam correctly works.
What should i do that see my webcam?
Thank for helping
Please check the Vector API, you can look that:
/**
* 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()
The deviceList is empty. You should call the isEmpty() method before calling the firstElement() method. If the isEmpty() return true, you can't call the firstElement() method.
if(deviceList!=null && !deviceList.isEmpty()){
device = (CaptureDeviceInfo) deviceList.firstElement();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.