Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Java plug-in doesn't enumerate my webcam

Started by Eskhan Jun 22, 2005 at 3:38 AM 3 replies 3.5k views
Original Post
Eskhan
Eskhan
I'm developing an applet that uses the webcam to transmit video. It runs fine when I run it in eclipse, but when I try to run it with java plug-in (in either IE or Firefox) It can't find any camera devices. My applet is signed and I have full permissions. I enumerate the webcam devices using

CaptureDeviceManager.getDeviceList( new VideoFormat(VideoFormat.RGB,
            new Dimension(viewSize), VideoFormat.NOT_SPECIFIED, byte[].class, VideoFormat.NOT_SPECIFIED));
I also tried getting the device directly by using the cameras name like this
    
CaptureDeviceInfo device = CaptureDeviceManager.getDevice("vfw:Creative WebCam NX (VFW):0");
--------------------Though this program be madness, yet there is a method in't
Son of Cain
Son of Cain
If it works in your IDE, but not in the browser, some exception is being thrown by the JRE. Get the stack of the java console and post here, if you don't identify the problem yourself, someone here on the forums will ;)

Son Of Cain
a.k.a javabeats at yahoo.ca
Eskhan
Eskhan
Well, that is the not so amusing part, the only exception being thrown is my own that I throw because I can't find any device, the jmf api methods that I use simply state that no camera device exists and returns.

Anyways, this is the stack trace.

number of devices 0Searching for [vfw:Creative WebCam NX (VFW):0]webcam.VideoTransmitException: No device found [ vfw:Creative WebCam NX (VFW):0]	at webcam.VideoTransmitNew.<init>(VideoTransmitNew.java:108)	at webtvclient.WebTVClient.getVideoTransmitNew(WebTVClient.java:377)	at webtvclient.ChildWindow$ChildWindowMessageHandler.actionPerformed(ChildWindow.java:244)	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)	at java.awt.Component.processMouseEvent(Unknown Source)	at javax.swing.JComponent.processMouseEvent(Unknown Source)	at java.awt.Component.processEvent(Unknown Source)	at java.awt.Container.processEvent(Unknown Source)	at java.awt.Component.dispatchEventImpl(Unknown Source)	at java.awt.Container.dispatchEventImpl(Unknown Source)	at java.awt.Component.dispatchEvent(Unknown Source)	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)	at java.awt.Container.dispatchEventImpl(Unknown Source)	at java.awt.Window.dispatchEventImpl(Unknown Source)	at java.awt.Component.dispatchEvent(Unknown Source)	at java.awt.EventQueue.dispatchEvent(Unknown Source)	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)	at java.awt.EventDispatchThread.run(Unknown Source)Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException	at webtvclient.ChildWindow$ChildWindowMessageHandler.actionPerformed(ChildWindow.java:245)	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)	at java.awt.Component.processMouseEvent(Unknown Source)	at javax.swing.JComponent.processMouseEvent(Unknown Source)	at java.awt.Component.processEvent(Unknown Source)	at java.awt.Container.processEvent(Unknown Source)	at java.awt.Component.dispatchEventImpl(Unknown Source)	at java.awt.Container.dispatchEventImpl(Unknown Source)	at java.awt.Component.dispatchEvent(Unknown Source)	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)	at java.awt.Container.dispatchEventImpl(Unknown Source)	at java.awt.Window.dispatchEventImpl(Unknown Source)	at java.awt.Component.dispatchEvent(Unknown Source)	at java.awt.EventQueue.dispatchEvent(Unknown Source)	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)	at java.awt.EventDispatchThread.run(Unknown Source)


the 0 in "number of devices 0" is the number returned by calling cameraDevices.size()
where cameraDevices is the Vector that was assigned by this call:
cameraDevices = CaptureDeviceManager.getDeviceList( new VideoFormat(VideoFormat.RGB,            new Dimension(viewSize), VideoFormat.NOT_SPECIFIED, byte[].class, VideoFormat.NOT_SPECIFIED));


When I run the applet in eclipse cameraDevices contains two CaptureDeviceInfo objects after this call.
--------------------Though this program be madness, yet there is a method in't
Son of Cain
Son of Cain
I'm not sure about it, it is just a guess, but isn't access to the webcam denied to the browser? If I'm not wrong, I suppose you have to enable it somewhere on IE, or the browser you're using.

Despite that, your code seems ok... isn't there any "register-like" operation for the manager before you can start catching devices?

Son Of Cain
a.k.a javabeats at yahoo.ca
Eskhan
Eskhan
Son of Cain - Thank you for taking your time to help me!

I ran the JMF diagnostics tool in http://java.sun.com/products/java-media/jmf/2.1.1/jmfdiagnostics.html
and it said it couldn't find the jmf class files, so I reinstalled jmf and this time put it in c:\java\jmf (it used to be c:\program files\jmf2.1.1.e), because I suspect that spaces and dots screws up the classpath variables, now I am able to see video in a browser applet.
--------------------Though this program be madness, yet there is a method in't

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.