Ask Your Question
2

please help me in configure the opencv for eclipse juno in java

asked 2013-05-16 01:40:34 -0600

mohammad mehdi gravatar image

updated 2013-05-26 05:34:54 -0600

Andrey Pavlenko gravatar image

i write a test program for opencv in java and i face with this exception my code is:

package ImageProc;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;

public class Test {
    public static void main(String[] args) {
        System.out.println("hello opencv");
        System.loadLibrary("opencv-245");
        VideoCapture capture = new VideoCapture(0);
        if(!capture.isOpened())
            System.out.println("Did not connect to camera!");
        else
            System.out.println("Found WebCam :"+capture.toString());
        Mat mat = new Mat();
        capture.retrieve(mat);
        Highgui.imwrite("me1.jpg", mat);
        capture.release();

    }
}

in exception is:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv-245 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
    at java.lang.Runtime.loadLibrary0(Runtime.java:845)
    at java.lang.System.loadLibrary(System.java:1084)
    at ImageProc.Test.main(Test.java:14)

for configure,i do this work:

  1. extract the opencv file in location c:
  2. open eclipse and create a project
  3. open the properties and go to java build path
  4. click on the add library button ,then select user library, click user library, click new and create a new library with this name opencv.245
  5. add opencv-245.jar file with click on add external jar file button
  6. and for native library location edit this and set this directory for this: c:/opencv/build/java/x64
  7. click finsih

i run this code and appear this exception please help me

edit retag flag offensive close merge delete

Comments

If my solution is working for you: i would appreciate it you accepted it as a solution by clicking the accept sign.

keltik gravatar imagekeltik ( 2013-05-25 17:40:51 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
4

answered 2013-05-22 07:14:07 -0600

keltik gravatar image

updated 2013-05-22 07:14:43 -0600

You have to do this (Step by Step explanation):
1.) Start eclipse, open new Project
2.) right click project, go into "properties"
3.) go into "Java Build path", click add external jars
4.) go into the folder where your jar is placed, "open"
5.) select the newly added jar and expand its "plus-sign"
6.) select "Native library location" and click edit
7.) here select the location where you have stored your c++ dll

If you do not know where your c++ dll and your jar file is:
-download openCV
-unpack it go into folder "build/java" (you will see opencv-245.jar)
-go into "build/java/x86" (you will see your dll)

edit flag offensive delete link more
2

answered 2013-05-26 05:38:46 -0600

Andrey Pavlenko gravatar image
edit flag offensive delete link more

Comments

the link lacks the step with "Native library location" and "add c++ dll", it also confused me when starting to program openCV in java.

keltik gravatar imagekeltik ( 2013-05-26 06:30:28 -0600 )edit
1

answered 2013-08-21 07:28:00 -0600

Baris Evrim Demiroz gravatar image

Here is a detailed, step by step tutorial on how to use OpenCV with Java+Eclipse: Using OpenCV Java with Eclipse

You can follow it to configure your environment.

edit flag offensive delete link more

Comments

This is actually a clear guide. Could you make it into a guide and submit a pullrequest using the how to contribute page?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-21 07:30:23 -0600 )edit
1

@StevenPuttemans I started working on it. It is very labor intensive to write and even modify a tutorial, so it will take time to make it into the repo.

Baris Evrim Demiroz gravatar imageBaris Evrim Demiroz ( 2013-08-23 09:12:52 -0600 )edit

Question Tools

Stats

Asked: 2013-05-16 01:40:34 -0600

Seen: 3,156 times

Last updated: Aug 21 '13