增加opencv 的centos 更换布局

main
wanghongjian 2024-02-19 16:39:06 +08:00
parent f79627415e
commit 9ae47910f2
6 changed files with 149 additions and 4 deletions

View File

@ -4,4 +4,3 @@ 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 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 docker push macrocc.com:3000/macrocc/tomcat-9-j8-centos:1.1.0
``` ```

117
lib/opencv-4.9.0.sh 100644
View File

@ -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

View File

@ -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

View File

@ -3,8 +3,8 @@
FROM centos FROM centos
COPY README.md /usr/local/README.md COPY README.md /usr/local/README.md
# 会自动解压到指定目录,不需要人为去解压 # 会自动解压到指定目录,不需要人为去解压
ADD jdk-8u401-linux-x64.tar.gz /usr/local ADD ../lib/jdk-8u401-linux-x64.tar.gz /usr/local
ADD apache-tomcat-9.0.85.tar.gz /usr/local ADD ../lib/apache-tomcat-9.0.85.tar.gz /usr/local
ENV MYPATH /usr/local ENV MYPATH /usr/local
WORKDIR $MYPATH WORKDIR $MYPATH