Ask Your Question

Revision history [back]

I'm also a new one who using java and opencv. Please see details how to setup java opencv with eclipse at this url;

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) {


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

    Mat frame = new Mat();   ;
    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);


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


enter code here

Hopefully, this could help..