• Post Reply Bookmark Topic Watch Topic
  • New Topic

use the webcam in java application  RSS feed

 
Jayashri Jadhav
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using netbeans IDE 7.1.1,JMstudio I'm making the application capture an image from a webcam, but my problem is that when I run that application first time it gives me proper output but when I run the same application again, it gives me this error:

java.io.IOException: Could not connect to capture device
javax.media.NoDataSourceException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.io.IOException: Could not connect to capture device
at javax.media.Manager.createDataSource(Manager.java:1012)

can anyone tell me why this is happening?

my code is:

/* Grab the default web cam*/
MediaLocator ml = new MediaLocator("vfw://0");

/* Create my data source */
DataSource ds = Manager.createDataSource(ml);

requestFormatResolution(ds);

/* Create & start my player */
Player p = Manager.createRealizedPlayer(ds);

p.start();
Component videoScreen = p.getVisualComponent();
 
BalaMurali dhar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide the complete code?
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

you should be able to work out where things go wrong from the Exception stack trace. Maybe also put some print statements between those lines, then you can see whether each object is being constructed successfully.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!