简体   繁体   中英

How to access webcams with JMF?

I would like to access my webcam with JMF, create a snapshot, and email it. I have working email code, but every time I try:

CaptureDeviceInfo inf = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture(Win32):0");
        player = Manager.createRealizedPlayer(inf.getLocator());

But I get a nullpointexception error. How to fix it?

This is because your code is not detecting the webcam

you must copy the jmf.properties file to the same directory as your executable jar

you will find the jmf.properties file int the lib folder of your jmf installation.

For me it was C:\Program Files\JMF2.1.1e\lib\jmf.properties

the device name is "Microsoft WDM Image Capture", what you pass to CaptureDeviceManager.getDevice(). the "vfw://0" part is the locator.

see Owen McGovern's example: http://geoffair.net/java/java_sun1.htm . It has working player and working snapshot code.

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.

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