Build OpenCV with Java Wrapper on Ubuntu 18.04

Premise

It is assumed that the JDK is installed.

procedure

Install Apache Ant. This is important. Jar cannot be made without Ant.

sudo apt-get install ant

--Download and unpack the current version of opencv Move to a place where the path does not include full-width characters. For example, /home/UserName/Documents/opencv-4.1.2 --Create an empty "build" folder in the folder where you extracted the opencv source

Screenshot from 2019-10-27 23-19-16.png

--Use Cmake-GUI to set the source to the parent folder of the opencv source and the path to the build folder created in build.

Screenshot from 2019-10-27 23-20-30.png

--Check Grouped and Advanced, and configure once --Finish as is with default native compilers --Turn off "BUILD_SHARED_LIBS" from the BUILD tree.

Screenshot from 2019-10-27 23-25-57.png

--Configure again --On the updated screen, check BUILD_FAT_JAVA_LIB from Ungrouped Entries.

Screenshot from 2019-10-27 23-26-14.png

--Configure again. --And Generate. --If you can do this, cmake-gui is finished. --Go to the created build folder from the terminal and use the make command.

~/Documents/opencv-4.1.2/build$ make -j4

The -j4 option specifies the number of cores. You don't have to.

--Finally, make sure that the jar file is created in the bin folder. The native library is in lib.

that's all

Other

When using the Native library in a project for eclipse development, expand the JRE library settings from the build path settings and edit the Native library path.

When releasing a project, write a script that sets the path to the native library in the startup option, or install opencv on the OS of your environment.

It may be good to use JavaCV from Maven with the following libraries.

When using it for compression / decompression processing of dcm4che, use the native library of opencv included in the dcm4che library.

Recommended Posts

Build OpenCV with Java Wrapper on Ubuntu 18.04
Build Java with Wercker
Build Zabbix on Ubuntu 20.04
[Java] Build Java development environment on Ubuntu & check execution
Build Java development environment with VS Code on Mac
Install OpenJDK7 (JAVA) on ubuntu 14.04
Build VNC Server on Ubuntu 20.04
Oracle Java 8 on Docker Ubuntu
Note Book: OpenCV v4.5.0-dev On Ubuntu 20.04 But Didn't work cmake build for Java
Install Java on WSL Ubuntu 18.04
Ubuntu on Windows build speed
Run java applet on ubuntu
Build Ubuntu 18.04.5 with dual boot
Build a Java project with Gradle
Install java with Ubuntu 16.04 based Docker
Install Java with zip on Windows
Build the latest Samba 4 on Ubuntu 20.04
Enable OpenCV with java8. (For myself)
Java build with mac vs code
Build a XAMPP environment on Ubuntu
Java cannot be installed on Ubuntu 13.04
How to build vim on Ubuntu 20.04
Build ffmpeg 4.3.1 on Ubuntu for Windows
Install ruby on Ubuntu 20.04 with rbenv
Using JupyterLab + Java with WSL on Windows 10
Install OpenJDK (Java) on the latest Ubuntu
Sobel filter using OpenCV on Android (Java)
CICS-Run Java applications-(3) Build management with Gradle
Java version control with jenv on OSX
DNS over HTTPS with Cloudflared on Ubuntu
Build a Java development environment on Mac
Build Java 8 development environment on AWS Cloud9
I tried using OpenCV with Java + Tomcat
Use cljstyle with Spacemacs on Ubuntu on WSL2
Build an environment with Docker on AWS
Run Ubuntu + ROS with Docker on Mac
Build Web Application Server (Java) on VPS
Try to build Java8 environment on Amazon Linux2
Build and install Wireshark Development Release (3.3.1) on Ubuntu
vagrant java build
Use OpenCV_Contrib (ArUco) in Java! (Part 1-Build) (OpenCV-3.4.4)
Easily switch Java versions with alias on macOS
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Build and test Java + Gradle applications with Wercker
Build a DHCP and NAT router on Ubuntu 16.04
Note Book: OpenCV with CUDA Install On Windows10
Build Java x Spring x VSCode x Gradle on Docker (1)
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Using Gradle with VS Code, build Java → run
Automate Java (Maven) project build with CircleCI + Orbs
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
Build a Java runtime environment on Sakura VPS
How to build a Pytorch environment on Ubuntu
tmux on Ubuntu
Build a Java development environment with VS Code
Using Java 8 with Bluemix (on Liberty Runtime & DevOps Service)
Install Java 8 (OpenJDK: Amazon Corretto) on macOS with Homebrew
Display characters on I2C 1602 LCD with Raspberry Pi 3 & Java
Install Java 8 (OpenJDK: Zulu Community) on macOS with Homebrew
(For myself) Build gitlab with ubuntu18.04 + docker for home (Note)
Build Java development environment with WSL2 Docker VS Code