From 9ae47910f29ee4f842abe953423ed538f1f438dd Mon Sep 17 00:00:00 2001 From: wanghongjian Date: Mon, 19 Feb 2024 16:39:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0opencv=20=E7=9A=84centos=20?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +- .../apache-tomcat-9.0.85.tar.gz | Bin .../jdk-8u401-linux-x64.tar.gz | Bin lib/opencv-4.9.0.sh | 117 ++++++++++++++++++ tomcat-jdk-opencv/DockerFIle | 29 +++++ DockerFile => tomcat-jdk/DockerFile | 4 +- 6 files changed, 149 insertions(+), 4 deletions(-) rename apache-tomcat-9.0.85.tar.gz => lib/apache-tomcat-9.0.85.tar.gz (100%) rename jdk-8u401-linux-x64.tar.gz => lib/jdk-8u401-linux-x64.tar.gz (100%) create mode 100644 lib/opencv-4.9.0.sh create mode 100644 tomcat-jdk-opencv/DockerFIle rename DockerFile => tomcat-jdk/DockerFile (88%) diff --git a/README.md b/README.md index 3020466..4e96e0b 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,4 @@ docker build -f .\DockerFile -t tomcat-9-j8-centos . # 推送 docker tag tomcat-9-j8-centos:latest macrocc.com:3000/macrocc/tomcat-9-j8-centos:1.1.0 docker push macrocc.com:3000/macrocc/tomcat-9-j8-centos:1.1.0 -``` - +``` \ No newline at end of file diff --git a/apache-tomcat-9.0.85.tar.gz b/lib/apache-tomcat-9.0.85.tar.gz similarity index 100% rename from apache-tomcat-9.0.85.tar.gz rename to lib/apache-tomcat-9.0.85.tar.gz diff --git a/jdk-8u401-linux-x64.tar.gz b/lib/jdk-8u401-linux-x64.tar.gz similarity index 100% rename from jdk-8u401-linux-x64.tar.gz rename to lib/jdk-8u401-linux-x64.tar.gz diff --git a/lib/opencv-4.9.0.sh b/lib/opencv-4.9.0.sh new file mode 100644 index 0000000..60a66ec --- /dev/null +++ b/lib/opencv-4.9.0.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +# Build and install OpenCV from source on CentOS 7 for graph-cut-ransac and MAGSAC++ + +# 切换到国内 +sed -i -e "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/CentOS-Linux-*.repo +sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-Linux-*.repo + +# install dependencies for opencv and magsac +yum update -y +yum install -y cmake3 eigen3-devel gflags-devel git +yum clean all && rm -rf /var/cache/yum # clean cache + +# Download opencv +git clone --depth 1 --branch 4.x https://github.com/opencv/opencv.git +cd opencv +mkdir build && cd build + +# Compile and install OpenCV with contrib modules +cmake3 -D CMAKE_BUILD_TYPE=RELEASE \ + -D CMAKE_INSTALL_PREFIX=/usr/local \ + -D INSTALL_C_EXAMPLES=OFF \ + -D INSTALL_PYTHON_EXAMPLES=OFF \ + -D PYTHON3_EXECUTABLE=/usr/bin/python3.6 \ + -D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3.6 \ + -D PYTHON3_VERSION_STRING="3.6.8" \ + -D BUILD_opencv_cudacodec=OFF \ + -D WITH_1394:BOOL=OFF \ + -D WITH_ARAVIS:BOOL=OFF \ + -D WITH_CLP:BOOL=OFF \ + -D WITH_CUDA:BOOL=OFF \ + -D WITH_EIGEN:BOOL=ON \ + -D WITH_FFMPEG:BOOL=OFF \ + -D WITH_GDAL:BOOL=OFF \ + -D WITH_GDCM:BOOL=OFF \ + -D WITH_GIGEAPI:BOOL=OFF \ + -D WITH_GPHOTO2:BOOL=OFF \ + -D WITH_GSTREAMER:BOOL=OFF \ + -D WITH_GSTREAMER_0_10:BOOL=OFF \ + -D WITH_GTK:BOOL=OFF \ + -D WITH_GTK_2_X:BOOL=OFF \ + -D WITH_HALIDE:BOOL=OFF \ + -D WITH_IMGCODEC_HDR:BOOL=OFF \ + -D WITH_IMGCODEC_PXM:BOOL=OFF \ + -D WITH_IMGCODEC_SUNRASTER:BOOL=OFF \ + -D WITH_INF_ENGINE:BOOL=OFF \ + -D WITH_IPP:BOOL=OFF \ + -D WITH_ITT:BOOL=OFF \ + -D WITH_JASPER:BOOL=OFF \ + -D WITH_JPEG:BOOL=OFF \ + -D WITH_LAPACK:BOOL=ON \ + -D WITH_LIBV4L:BOOL=OFF \ + -D WITH_MFX:BOOL=OFF \ + -D WITH_OPENCL:BOOL=OFF \ + -D WITH_OPENCLAMDBLAS:BOOL=OFF \ + -D WITH_OPENCLAMDFFT:BOOL=OFF \ + -D WITH_OPENCL_SVM:BOOL=OFF \ + -D WITH_OPENEXR:BOOL=OFF \ + -D WITH_OPENGL:BOOL=OFF \ + -D WITH_OPENMP:BOOL=OFF \ + -D WITH_OPENNI:BOOL=OFF \ + -D WITH_OPENNI2:BOOL=OFF \ + -D WITH_OPENVX:BOOL=OFF \ + -D WITH_PNG:BOOL=OFF \ + -D WITH_PROTOBUF:BOOL=OFF \ + -D WITH_PTHREADS_PF:BOOL=ON \ + -D WITH_PVAPI:BOOL=OFF \ + -D WITH_QT:BOOL=OFF \ + -D WITH_QUIRC:BOOL=OFF \ + -D WITH_TBB:BOOL=OFF \ + -D WITH_TIFF:BOOL=OFF \ + -D WITH_UNICAP:BOOL=OFF \ + -D WITH_V4L:BOOL=OFF \ + -D WITH_VA:BOOL=OFF \ + -D WITH_VA_INTEL:BOOL=OFF \ + -D WITH_VTK:BOOL=OFF \ + -D WITH_WEBP:BOOL=OFF \ + -D WITH_XIMEA:BOOL=OFF \ + -D WITH_XINE:BOOL=OFF \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_TESTS:BOOL=OFF \ + -D BUILD_TIFF:BOOL=OFF \ + -D BUILD_USE_SYMLINKS:BOOL=OFF \ + -D BUILD_WEBP:BOOL=OFF \ + -D BUILD_WITH_DEBUG_INFO:BOOL=OFF \ + -D BUILD_WITH_DYNAMIC_IPP:BOOL=OFF \ + -D BUILD_ZLIB:BOOL=OFF \ + -D BUILD_opencv_apps:BOOL=OFF \ + -D BUILD_opencv_dnn:BOOL=OFF \ + -D BUILD_opencv_highgui:BOOL=OFF \ + -D BUILD_opencv_imgcodecs:BOOL=OFF \ + -D BUILD_opencv_java_bindings_generator:BOOL=OFF \ + -D BUILD_opencv_js:BOOL=OFF \ + -D BUILD_opencv_ml:BOOL=OFF \ + -D BUILD_opencv_objdetect:BOOL=OFF \ + -D BUILD_opencv_photo:BOOL=OFF \ + -D BUILD_opencv_python_bindings_generator:BOOL=OFF \ + -D BUILD_opencv_shape:BOOL=OFF \ + -D BUILD_opencv_stitching:BOOL=OFF \ + -D BUILD_opencv_superres:BOOL=OFF \ + -D BUILD_opencv_ts:BOOL=OFF \ + -D BUILD_opencv_video:BOOL=OFF \ + -D BUILD_opencv_videoio:BOOL=OFF \ + -D BUILD_opencv_videostab:BOOL=OFF \ + -D BUILD_opencv_world:BOOL=OFF \ + -D BUILD_opencv_calib3d:BOOL=ON \ + -D BUILD_opencv_features2d:BOOL=ON \ + -D BUILD_opencv_imgproc:BOOL=ON \ + -D BUILD_opencv_core:BOOL=ON \ + -D BUILD_opencv_flann:BOOL=ON .. + +# compile and install OpenCV +make -j && make install + +# Remove OpenCV source +cd ../.. +rm -rf opencv \ No newline at end of file diff --git a/tomcat-jdk-opencv/DockerFIle b/tomcat-jdk-opencv/DockerFIle new file mode 100644 index 0000000..81ce204 --- /dev/null +++ b/tomcat-jdk-opencv/DockerFIle @@ -0,0 +1,29 @@ +# vim Dockerfile + +FROM centos +COPY README.md /usr/local/README.md +# 会自动解压到指定目录,不需要人为去解压 +ADD ../lib/jdk-8u401-linux-x64.tar.gz /usr/local +ADD ../lib/apache-tomcat-9.0.85.tar.gz /usr/local +ADD ../lib/opencv-4.9.0.sh /usr/local/opencv-4.9.0.sh + +ENV MYPATH /usr/local +WORKDIR $MYPATH +RUN mv jdk1.8.0_401/ java/ +RUN mv apache-tomcat-9.0.85/ tomcat/ +ENV JAVA_HOME $MYPATH/java +ENV JAVA_VERSION jdk-8u401-linux-x64 +ENV TOMCAT_HOME $MYPATH/tomcat +ENV TOMCAT_VERSION apache-tomcat-9.0.85 +ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar +ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin +ENV OPENCV_VERSION: 4.9.0 +# 执行opencv 代码 +RUN /usr/local/opencv-4.9.0.sh + +EXPOSE 8080 + +VOLUME ["$TOMCAT_HOME/logs/","$TOMCAT_HOME/webapps"] +# 注意:tail -F ,这里如果用小写的f,启动容器的时候打印完日志后会退出,用大写-F容器才会停留 +CMD $TOMCAT_HOME/bin/startup.sh && tail -F $TOMCAT_HOME/logs/catalina.out + diff --git a/DockerFile b/tomcat-jdk/DockerFile similarity index 88% rename from DockerFile rename to tomcat-jdk/DockerFile index 283f3da..a42f28f 100644 --- a/DockerFile +++ b/tomcat-jdk/DockerFile @@ -3,8 +3,8 @@ FROM centos COPY README.md /usr/local/README.md # 会自动解压到指定目录,不需要人为去解压 -ADD jdk-8u401-linux-x64.tar.gz /usr/local -ADD apache-tomcat-9.0.85.tar.gz /usr/local +ADD ../lib/jdk-8u401-linux-x64.tar.gz /usr/local +ADD ../lib/apache-tomcat-9.0.85.tar.gz /usr/local ENV MYPATH /usr/local WORKDIR $MYPATH