When I installed OpenCV 3.2.0 on Mac, I had a lot of trouble, so make a note of it. It seems that it can be used immediately after downloading on Windows, but it was quite troublesome on Mac.
· OS X El Capitan 10.11.6 ・ Ecip Seneon ・ OpenCV 3.2.0
If you don't have Homebrew installed, install it.
Execute the following command brew tap homebrew/science brew install opencv3 --with-java
If you get an error such as not linking to cmake, you can do as you are told.
If you can install it, you will find the following two files in the /usr/local/Cellar/opencv3/3.2.0/share/OpenCV/java folder. +opencv-320.jar +libopencv_java320.dylib
This completes the OpenCV installation. Next, set the Eclipse side.
I had a hard time setting up Eclipse unexpectedly. First, create a new project.
File-> Properties-> Java Build Path-> Libraries tab
"Add Library"-> "User Library"-> "User Libraries" button Enter "New"-> "opencv-3.2.0"-> "OK"
Click "Add External JARs" and specify "opencv-320.jar" I wasn't sure if I could run it if I specified Jar. After a lot of research, it seems that you have to specify the native library as well.
Select "Native library location" and click "Edit" Specify /usr/local/Cellar/opencv3/3.2.0/share/OpenCV/java as the path (It seems that up to 3.1 you specified libopencv_java ◯◯◯ .dylib, but in 3.2 it will not work unless you specify ~ / java)
If you can write the source code and execute it, it's OK.
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.loadLibrary(Core.NATIVE_LIBRARY_NAME); Mat m = Mat.eye(3, 3, CvType.CV_8UC1); System.out.println("m = " + m.dump()); } }
m = [ 1, 0, 0; 0, 1, 0; 0, 0, 1]
Recommended Posts