如何使用 JMF 访问网络摄像头?
我想使用 JMF 访问我的网络摄像头、创建快照并通过电子邮件发送。我有有效的电子邮件代码,但每次我尝试:
CaptureDeviceInfo inf = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture(Win32):0");
player = Manager.createRealizedPlayer(inf.getLocator());
但我收到 nullpointexception
错误。如何修复它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为您的代码未检测到网络摄像头,
您必须将 jmf.properties 文件复制到可执行 jar 所在的目录中,
您将在 jmf 安装的 lib 文件夹中找到 jmf.properties 文件。
对我来说是 C:\Program Files\JMF2.1.1e\lib\jmf.properties
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
设备名称是“Microsoft WDM Image Capture”,您传递给 CaptureDeviceManager.getDevice() 的名称。 “vfw://0”部分是定位器。
请参阅 Owen McGovern 的示例:http://geoffair.net/java/java_sun1.htm。它有工作播放器和工作快照代码。
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.