1、官网下载opencv
2、下载opencv并解压
unzip opencv-3.4.7.zip
cd opencv-3.4.7
mkdir build
cd build/
3、安装cmake
yum remove cmake -y ; yum install -y gcc gcc-c++ make automake openssl openssl-devel
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz ; tar -zxf cmake*.tar.gz
cd cmake* ; ./bootstrap ; gmake -j `grep 'processor' /proc/cpuinfo | wc -l` ; gmake install
4、链接
/usr/local/bin/cmake --version
ln -s /usr/local/bin/cmake /usr/bin/
5、检查cmake是否安装成功
cmake -version
6、编译opencv的java版本
yum install ant
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTS=OFF ..
make -j4
make install
7、
cp /usr/local/share/java/opencv4/libopencv_java452.so /usr/lib/
java
if (SystemUtils.IS_OS_WINDOWS) {
System.out.println("windows启动OpenCV");
String libName = "lib/opencv_java452.dll";
URL url = ClassLoader.getSystemResource(libName);
System.load(url.getPath());
} else if (SystemUtils.IS_OS_LINUX) {
System.out.println("linux启动OpenCV");
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}