官方文档最准确的安装参考:https://docs.opencv.org/4.6.0/d7/d9f/tutorial_linux_install.html
安装参考:https://blog.csdn.net/Taylor_0522/article/details/119172807
使用参考:https://blog.wangqi.love/articles/Java/Java%E8%B0%83%E7%94%A8opencv.html
FROM coding-public-docker.pkg.coding.net/public/docker/openjdk:8
docker build -t face-petition-java:1.0.0.0802 .
docker run -it --entrypoint=/bin/bash face-petition-java:1.0.0.0802
把内网地址mirrors.tencentyun.com换成外网mirrors.tencent.com
docker cp 3abdb23ac326:/etc/apt/sources.list /data/mart/face_insight/java_dockerfile/
docker cp /data/mart/face_insight/java_dockerfile/sources.list 3abdb23ac326:/etc/apt/
apt update
apt install build-essential cmake net-tools git vim unzip iputils-ping -y
apt install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libswresample-dev libavresample-dev libgphoto2-dev
apt install libgtk3.0 #安装过程中选 6 Asia 70 Shanghai
apt install libgstreamer1.0-dev libgstreamer1.0-dev
apt install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
apt install ant
wget https://github.com/opencv/opencv/archive/4.6.0.zip
unzip 4.6.0.zip
cd opencv-4.6.0
mkdir build && cd build
cmake参数指令介绍
CMAKE_BUILD_TYPE:build类型(Debug,Release,…),CMAKE_BUILD_TYPE=Debug;
CMAKE_INSTALL_PREFIX:工程安装目录,所有生成和调用所需的可执行程序,库文件,头文件都会安装到该路径下,Unix/Linux下默认为/usr/local, windows下默认为C:\Program Files;
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv460 ..
make -j8
make install
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_world=ON -D CMAKE_INSTALL_PREFIX=/usr/local/opencv460 -DBUILD_TESTS=OFF -DBUILD_opencv_java=ON ..
make -j8
make install
/usr/local/opencv460/share/java/opencv4
libopencv_java460.so opencv-460.jar
docker commit 3abdb23ac326 face-petition-java-new:1.0.0.0802
docker tag face-petition-java-new:1.0.0.0802 xx/face-petition-java-new:1.0.0.0802
docker login -u xx -p xx xx-docker.pkg.coding.net
docker push xx/face-petition-java-new:1.0.0.0802
Failed to fetch http://mirrors.tencentyun.com/debian/pool/main/v/vim/xxd_8.1.0875-5_amd64.deb Something wicked happened resolving 'mirrors.tencentyun.com:http' (-5 - No address associated with hostname)
报错解决
ping后发现网络不通
ping mirrors.tencentyun.com
cat /etc/apt/sources.list
把内网地址mirrors.tencentyun.com换成外网mirrors.tencent.com
deb http://mirrors.tencent.com/debian buster main contrib non-free
deb http://mirrors.tencent.com/debian buster-updates main contrib non-free
deb http://mirrors.tencent.com/debian-security buster/updates main
#deb http://mirrors.tencent.com/debian buster-backports main contrib non-free
#deb http://mirrors.tencent.com/debian buster-proposed-updates main contrib non-free
deb-src http://mirrors.tencent.com/debian buster main contrib non-free
deb-src http://mirrors.tencent.com/debian buster-updates main contrib non-free
deb-src http://mirrors.tencent.com/debian-security buster/updates main
#deb-src http://mirrors.tencent.com/debian buster-backports main contrib non-free
#deb-src http://mirrors.tencent.com/debian buster-proposed-updates main contrib non-free
docker cp 3abdb23ac326:/etc/apt/sources.list /data/mart/face_insight/java_dockerfile/
docker cp /data/mart/face_insight/java_dockerfile/sources.list 3abdb23ac326:/etc/apt/
未生成jar包问题:https://blog.csdn.net/weixin_43919656/article/details/121949469
完整生成jar包的配置以及最终的测试:https://www.bbsmax.com/A/x9J2X8kVd6/