-
problem in capturing webcam image
To capture image directly, I'm using the following code:
import java.io.*;
import java.awt.*;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.util.*;
import javax.media.format.RGBFormat;
import javax.media.format.VideoFormat;
import javax.media.*;
import javax.media.control.*;
import javax.media.util.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.*;
import javax.media.*;
import javax.media.datasink.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.util.*;
import javax.media.control.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import com.sun.image.codec.jpeg.*;
import java.io.IOException;
import java.util.Locale;
import javax.imageio.ImageReader;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
import com.sun.media.protocol.vfw.VFWCapture; // JMF 2.1.1e version
// set up player
JPanel videoPanel = new JPanel();
// note I just set the media locator directly
MediaLocator ml = new MediaLocator("vfw://0");
try {
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp;
if ((comp = player.getVisualComponent()) != null) {
videoPanel.add(comp, BorderLayout.CENTER);
videoPanel.setSize(new Dimension(320, 240));
videoPanel.setMinimumSize(new Dimension(320, 240));
videoPanel.setMaximumSize(new Dimension(320, 240));
}
playerUp=true;
}
catch (Exception e) {
// process error
}
// action code on capture button
public void actionPerformed(ActionEvent e) {
JComponent c = (JComponent) e.getSource();
if (c == capture) {
// Grab the frame
FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
Buffer buf = fgc.grabFrame();
// Convert to image
BufferToImage btoi = new BufferToImage((VideoFormat)buf.getFormat());
Image img = btoi.createImage(buf);
// now go and display the captured image
...
}
}
But it gives the error package javax.media does not exist. I'm using jdk 1.4. Classpath is set becoz it doesn't give error for javax.swing, which I'm using in my code. What could be the problem?
-
Those classes are part of the standard jsdk. If they are, I dont see them in the standard API for 1.4. Have you downloaded JMF?
Similar Threads
-
By vikassheelgupta in forum Java
Replies: 0
Last Post: 01-06-2006, 01:12 AM
-
By rechmbrs in forum Java
Replies: 0
Last Post: 07-11-2005, 09:41 PM
-
Replies: 0
Last Post: 10-30-2002, 04:39 AM
-
By Shravan in forum VB Classic
Replies: 5
Last Post: 05-24-2002, 05:10 AM
-
By Michael Shutt in forum XML
Replies: 0
Last Post: 06-26-2001, 11:51 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks