Ask Your Question

Revision history [back]

public class CapturingExample{

  CvCapture capture;
  IplImage frame;
  public void Capturing() {  
  capture = cvCreateCameraCapture(-1);
  if(capture!=null)
  {
      while(true)
      {
          frame = cvQueryFrame(capture);
          cvShowImage("heloo", frame.asCvMat());

          cvSaveImage("hi.jpg", frame.asCvMat());//just saving image..

      }
  }

  else System.out.println("errro");

}

 public static void main(final String[] args) {
 CapturingExample example = new CapturingExample();
 example.Capturing();
}

}

public class CapturingExample{
   CvCapture capture;
  IplImage frame;
  public void Capturing() {  
  capture = cvCreateCameraCapture(-1);
  if(capture!=null)
  {
      while(true)
      {
          frame = cvQueryFrame(capture);
          cvShowImage("heloo", frame.asCvMat());

          cvSaveImage("hi.jpg", frame.asCvMat());//just saving image..

      }
  }

  else System.out.println("errro");

}

 public static void main(final String[] args) {
 CapturingExample example = new CapturingExample();
 example.Capturing();
}

}

 public class CapturingExample{
   CvCapture capture;
   IplImage frame;
   public void Capturing() {  
   capture = cvCreateCameraCapture(-1);
   if(capture!=null)
   {
       while(true)
       {
           frame = cvQueryFrame(capture);
           cvShowImage("heloo", frame.asCvMat());

           cvSaveImage("hi.jpg", frame.asCvMat());//just saving image..

       }
   }

   else System.out.println("errro");
}

}

  public static void main(final String[] args) {
 CapturingExample example = new CapturingExample();
 example.Capturing();
 }
}

}

Your code should be like this.
    public class CapturingExample{
     CvCapture capture;
     IplImage frame;
     public void Capturing() {  
    capture = cvCreateCameraCapture(-1);
    if(capture!=null)
    {
        while(true)
        {
            frame = cvQueryFrame(capture);
            cvShowImage("heloo", frame.asCvMat());

            cvSaveImage("hi.jpg", frame.asCvMat());//just saving image..

        }
    }

    else System.out.println("errro");
  }

     public static void main(final String[] args) {
     CapturingExample example = new CapturingExample();
     example.Capturing();
    }
}

Here you can get some hints for converting opencv to javacv. Hints for Converting OpenCV C/C++ code to JavaCV