Ask Your Question
0

Does OpenCV currently supply full APIs for Java?

asked 2013-05-22 08:04:56 -0600

Bao Li gravatar image

Hi all, I am trying to use the Java api of OpenCV 2.4.5 to develop a project for face detection from offline videos. However, after some days I found that in the APIs supplied, the VideoCapture class only supports to load streams from camera. And the SetImageROI method is also not included. Thus I am confused that whether the APIs supplied currently are only a subset. If it is the case, is there a plan that someday APIs of Java will be the same as C++/Python? Thanks!

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2013-11-10 11:25:03 -0600

VideoCapture supports now capturing from video file in Java (http://code.opencv.org/issues/3207).

As per SetImageROI, that corresponds to the C interface. As per my understanding, only the C++ interface is exported to Java.

edit flag offensive delete link more
0

answered 2013-06-12 08:00:00 -0600

Nimit gravatar image

I'm also a new one who using java and opencv. Please see details how to setup java opencv with eclipse at this url; http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html.

I test run with version 2.4.5 as the code below. It can run fine. Have a look the output images at the workspace directory.

enter code here

import org.opencv.core.Mat; import org.opencv.core.Size; import org.opencv.highgui.Highgui; import org.opencv.highgui.VideoCapture; import org.opencv.imgproc.Imgproc;

public class Main {

public static void main(String[] args) {

    System.loadLibrary("opencv_java245");

    VideoCapture cap = new VideoCapture(0);
    if (!cap.isOpened()){
        System.out.println("Did not connect to camera");
    }
    else
        System.out.println("found webcam: "+cap.toString());

    Mat frame = new Mat();        
    cap.read(frame);
    Highgui.imwrite("me1.jpg", frame);
    Mat frameBlur = new Mat();
    Imgproc.blur(frame, frameBlur,  new Size(5,5));
    Highgui.imwrite("me1-blurred1.jpg", frameBlur);

    Imgproc.GaussianBlur(frame, frameBlur,  new Size(25,25), 20);
    Highgui.imwrite("me1-blurred2.jpg", frameBlur);

    cap.release();

    System.out.println("End of program..");
}

}

enter code here

Hopefully, this could help..

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-05-22 08:04:56 -0600

Seen: 565 times

Last updated: Nov 10 '13