problem in capturing webcam image


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: problem in capturing webcam image

  1. #1
    Join Date
    Feb 2006
    Posts
    9

    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?

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    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

  1. Sending mail with image problem
    By vikassheelgupta in forum Java
    Replies: 0
    Last Post: 01-06-2006, 02:12 AM
  2. Replies: 0
    Last Post: 07-11-2005, 10:41 PM
  3. Reliability Problem
    By elise in forum .NET
    Replies: 0
    Last Post: 10-30-2002, 05:39 AM
  4. Replies: 5
    Last Post: 05-24-2002, 06:10 AM
  5. problem with data islands and images
    By Michael Shutt in forum XML
    Replies: 0
    Last Post: 06-26-2001, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center