These days in Java to do an image processing things. I was following this guide (point me), and the tutorial behind it was OpenCV, so I started setting up the environment.
I found a OPENCV jar package and put the jar package in my project. And then copied a demo code. A code like this in the demo
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
The function of this sentence is to load a native library, where the value of Native_library_nmae is opencv_java310. In plain terms, Linux is loading libopcv_java310.so. For Windows is Opencv_java310.dll. It is not possible to have jar files alone. So I went to the official website to download the opencv-3.1.0, after decompression
cmake .make
You can get the library file. There's libopencv_java310 in there. For convenience, you can copy all the so files in the Lib directory into the/usr/local/lib directory.
But it's not over here, and you have to tell the IDE where to find the library. For Eclipse, you can set the native library path directly. For idea, add in the JVM options in Run->edit configurations
-Djava.library.path="/usr/local/lib"
Refer to these two links specifically:
Eclipse
Idea
Focus issueopencv-3.1.0 removed the Highgui, the original Highgui divided into Imgcodecs (Imread/imwrite and Friends) and Videoio (Videocapture, Videowriter) opencv-3.1.0 removed the Highgui, the original Highgui was divided into Imgcodecs (Imread/imwrite and Friends) and Videoio (Videocapture, Videowriter) opencv-3.1.0 removed the Highgui, the original Highgui was divided into Imgcodecs (Imread/imwrite and Friends) and Videoio (Videocapture, Videowriter)
For details, refer to this: Portal
The tutorial I gave originally was an example of a 2.4.* version. There is a code like this:
ImportOrg.opencv.core.Core;ImportOrg.opencv.core.Mat;ImportOrg.opencv.highgui.Highgui;ImportOrg.opencv.imgproc.Imgproc; Public class Main { Static intWidthStatic intHeightStatic DoubleAlpha =2;Static DoubleBeta = -; Public Static void Main(string[] args) {Try{system.loadlibrary (core.native_library_name); Mat Source = Highgui.imread ("Grayscale.jpg", Highgui.cv_load_image_grayscale); Mat Destination =NewMat (Source.rows (), Source.cols (), Source.type ()); Imgproc.equalizehist (source, destination); Highgui.imwrite ("Contrast.jpg", destination); }Catch(Exception e) {System.out.println ("Error:"+ e.getmessage ()); } }}
This code is basically compiled under 3.*. Will die on statements related to Highui. Similarly, if you download version 2.4, the compilation will fail. This time it will die on the following sentence.
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
So let's use the 3.x version. Just change the code, please. Change the Highgui.imread to Imgcodecs.imread.
Configuring the OpenCV jar under Linux