[OpenCV3.2.0] Eclipse (Java) settings (for Mac)

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.

environment

· OS X El Capitan 10.11.6 ・ Ecip Seneon ・ OpenCV 3.2.0

1. Install 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.

2. Eclipse settings

I had a hard time setting up Eclipse unexpectedly. First, create a new project.

+ Open the "Libraries" tab on the "Java Build Path" screen

File-> Properties-> Java Build Path-> Libraries tab

+ Add library

"Add Library"-> "User Library"-> "User Libraries" button Enter "New"-> "opencv-3.2.0"-> "OK"

+ Specify Jar file

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.

+ Specify native library

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)

3. Operation check

If you can write the source code and execute it, it's OK.

Source code:

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()); } }

Execution result

m = [ 1, 0, 0; 0, 1, 0; 0, 0, 1]

Recommended Posts

[OpenCV3.2.0] Eclipse (Java) settings (for Mac)
Summary of Java environment settings for myself [mac]
Java development environment (Mac, Eclipse)
Java installation location for mac
Enable OpenCV with java8. (For myself)
Build Java development environment (for Mac)
Eclipse installation and code completion enhancements (Mac for Java development)
[Java & SpringBoot] Environment Construction for Mac
Settings for SSL debugging in Java
Enable code completion in Eclipse for Mac
Download and install Eclipse (Java) (Mac version)
Convenient plugin for Eclipse JAVA development: Decompiler
Eclipse formatter settings
For JAVA learning (2018-03-16-01)
2017 IDE for Java
Java for statement
Eclipse Pleiades All in One for Mac released
Java management and STS (Eclipse) build path settings
Technology for reading Java source code in Eclipse
Initial settings for rewriting Java projects to Kotlin
[Mac / Java / Eclipse / PostgreSQL] Connect Java application and database
[Java] for statement, while statement
Java (eclipse) installation procedure
Install Java on Mac
[Java] Package for management
[Java] for statement / extended for statement
Desktop: OpenCV Java Repository
Mac Java Home Directory
Countermeasures for Java OutOfMemoryError
Use OpenCV in Java
[Java] PDF viewing settings
NLP for Java (NLP4J) (2)
[Java] Environment construction procedure for developing struts 1.3 with Eclipse
(Memo) Java for statement
NLP for Java (NLP4J) (1)
[For beginners] Install JDK + Eclipse on Mac (without Pleiades All-in-One)
Learning Java framework # 1 (Mac version)
How to uninstall Java 8 (Mac)
Ubuntu (Mac style) initial settings
Java debug execution [for Java beginners]
[Java] Basic statement for beginners
Desktop: OpenCV Emboss For Rectangle
[Java] Precautions for type conversion
Gradle settings for using JUnit 5
Eclipse shortcut keys (Windows, Mac)
2018 Java Proficiency Test for Newcomers-Basics-
Null-safe program in Java (Eclipse)
Java thread safe for you
[Java] Summary of for statements
Java for beginners, data hiding
First Java development in Eclipse
[Java] Tips for writing source
Simplify java version switching (Mac)
Desktop: OpenCV EqualizeHist For YUV
Install tomcat + eclipse on mac
Java application for beginners: stream
Java while and for statements
I just want to write Java using Eclipse on my Mac
[ev3 × Java] leJOS development environment construction (Eclipse on Mac OSX / bluetooth)