Ask Your Question
0

CvCreateFileCapture in Java

asked 2013-07-12 12:13:25 -0600

updated 2013-07-12 15:28:05 -0600

Kirill Kornyakov gravatar image

How can I use CvCreateFileCapture / CvQueryFrame in Java using Java wrapper?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-07-12 15:26:31 -0600

Kirill Kornyakov gravatar image

Whether you working on desktop or Android? Are you going to read from file or from camera?

On Android you can only read from camera, and you should use the same VideoCapture class: http://docs.opencv.org/java/org/opencv/highgui/VideoCapture.html . Video IO is not available. Unfortunately I don't know the current status on desktop Java, but you can try to use the same class.

edit flag offensive delete link more
0

answered 2013-07-17 17:56:29 -0600

DreamRunner gravatar image

updated 2013-07-17 18:10:23 -0600

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

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-12 12:13:25 -0600

Seen: 1,888 times

Last updated: Jul 17 '13