Linux 编译java环境的opencv_java410.so
示例为 OpenCv4.1.0版本
系统环境:Linux localhost.localdomain 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
1. 下载源码
2. 安装
安装前确保已经安装cmake的版本 > 3.5
## 创建安装目录
[root@localhost /]# mkdir -p /usr/local/opencv_make
[root@localhost opencv_make]# cd /usr/local/opencv_make
[root@localhost opencv_make]# mkdir release
##解压
[root@localhost opencv_make]# tar -zvxf opencv-4.1.0
[root@localhost opencv_make]# cd opencv-4.1.0
## 创建编译目录
[root@localhost opencv-4.1.0]# mkdir build
[root@localhost build]# cd build
## 需要手动安装3.5版本以上的cmake,参考另一篇文章;yum 下载的cmake为低版本,进行编译会报错
## 安装编译所需的软件
[root@localhost build]# yum -y install gcc gcc-c++ gtk±devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig python libtool nasm build-essential ant
[root@localhost build]# cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv_make/release -DBUILD_TESTS=OFF ..
## 编译
[root@localhost build]# make -j8 & make
[root@localhost build]# cd /usr/local/opencv_make/release/share/OpenCV/java
编译时间比较长, 请耐心等待;编译中的警告可以忽略。