Where can I get a jar for openCV?

Where are the Java jar libraries for openCV kernel extensions so that I can import them into my Java code?

I can not find a single place where they learned how to properly configure everything. I am using Ubuntu 12.04 and I have openCV installed. I want to use it in the eclipse IDE, and eclipse needs a jar file so that I can use the openCV functions. I saw the following link that used import org.opencv.core.Core;

How can I get these .jar files?

+8
java eclipse opencv javacv
source share
1 answer

You can find banks for openCV for linux carrying over the internet, for example this link . However, this will not work if you have your own openCV libraries that should do their job.

The surefire way to get openCV in your eclipse java project is to compile your own jar file from the source so that it is accessible as described here: https://udallascs.wordpress.com/2014/03/30/adding-opencv -and-configuring-to-work-with-eclipse-and-java /

Here is a list of instructions for Linux, open a terminal and run the following commands:

 cd ~ mkdir Vision cd Vision git clone git://github.com/Itseez/opencv.git cd opencv mkdir build cd build cmake -DBUILD_SHARED_LIBS=OFF .. make -j8 

If everything works, your banks will be under the bin folder:

 ./bin/opencv-300.jar 

Move this opencv-300.jar to the lib directory in your project and enable it as an external jar. It uses the barebones program.

 import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; public class Main { public static void main(String[] args) { System.out.println("Welcome to OpenCV " + Core.VERSION); System.out.println(System.getProperty("java.library.path")); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); Mat m = Mat.eye(3, 3, CvType.CV_8UC1); System.out.println("m = " + m.dump()); } } 

Inside eclipse, your jar file will need the built-in libraries that you created earlier. So in eclipse go to:

 Project->Properties->Java Build Path->Libraries tab-> Add external jars -> opencv-300.jar 

Then double-click: "Location of the source library" and type in build / lib where you built it, in my case: /home/el/Vision/opencv/build/lib

Run the java program, the program will print:

 Welcome to OpenCV 3.0.0-dev /home/el/Vision/opencv/build/lib m = [ 1, 0, 0; 0, 1, 0; 0, 0, 1] 

If you want to transfer this program to someone else and be able to run it, they will also need to have an open version 3.0.0 available on their system, otherwise the Java program will not find the library and exit immediately.

Why is it so complicated, why is it not just a jar?

Since openCV is written in C, and the jar file is just a window in this world of C. Thus, we need to make the rube goldberg machine to make methods in OpenCV available to your java application.

+13
source share

All Articles