0 Replies Latest reply on May 10, 2012 8:10 PM by 936557

    Change the video resolution when capturing a WEB-cameras

    936557
      Language: Java
      It is used in addition: JMF

      When capturing video from WEB-cameras with JMF - getting the video is at the lowest resolution.
      Can you please tell how to change the video resolution?

      The code by which the captured image (no SWING-forms):

      MediaLocator getWebCam = new MediaLocator("vfw://0");
      private Player player;
      Timer timer = new Timer(40, this);

      public BufferedImage grabFrameImage() {

      Image image = null;
      FrameGrabbingControl frameGrabbingControl = null;

      if (player != null)
      frameGrabbingControl = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
      Buffer buffer = frameGrabbingControl.grabFrame();
      if (buffer != null)
      image = new BufferToImage((VideoFormat) buffer.getFormat()).createImage(buffer);
      if (image != null)
      return (BufferedImage) image;

      return null;
      }

      public WorkWithWebCam() throws NoDataSourceException, IOException, NoPlayerException {

      initComponents();
      player = Manager.createPlayer(Manager.createDataSource(getWebCam));
      player.start();

      }
      private void jButton1ActionPerformed(ActionEvent e) {
      timer.start();
      }

      public static void main(String args[]) {
      EventQueue.invokeLater(new Runnable() {
      public void run() {
      try{
      new WorkWithWebCam().setVisible(true);
      }catch(Exception ex){}
      }
      });
      }

      public void actionPerformed(ActionEvent e) {
      panelMain.getGraphics().drawImage(this.grabFrameImage(), 0, 0, 400, 300, null);
      }

      P.S. Can you please tell how this forum can be identified code \ listing?