-
Notifications
You must be signed in to change notification settings - Fork 4
/
Containerfile.compile_opencv
103 lines (94 loc) · 3.95 KB
/
Containerfile.compile_opencv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
FROM {{ image_name }}:{{ base_tag }}
ARG DEBIAN_FRONTEND=noninteractive
ARG PYTHON_VERSION={{ python_version }}
ARG OPENCV_VERSION={{ opencv_version }}
# OpenCV Dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential git unzip pkg-config \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 \
gstreamer1.0-qt5 gstreamer1.0-pulseaudio \
libjpeg-dev libpng-dev libtiff-dev \
libavcodec-dev libavformat-dev libswscale-dev \
libgtk2.0-dev libcanberra-gtk* \
libxvidcore-dev libx264-dev libgtk-3-dev \
libtbb2 libtbb-dev libdc1394-22-dev \
libv4l-dev v4l-utils \
libavresample-dev libvorbis-dev libxine2-dev \
libfaac-dev libmp3lame-dev libtheora-dev \
libopencore-amrnb-dev libopencore-amrwb-dev \
libopenblas-dev libatlas-base-dev libblas-dev \
liblapack-dev libeigen3-dev gfortran \
libhdf5-dev protobuf-compiler \
libprotobuf-dev libgoogle-glog-dev libgflags-dev qt5-default qv4l2 curl \
file && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
pip install cmake
# Required for Cuda Compiler
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc-8 g++-8 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8 && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
WORKDIR /home
RUN git clone --depth 1 https://github.com/opencv/opencv.git -b ${OPENCV_VERSION} && \
git clone --depth 1 https://github.com/opencv/opencv_contrib.git -b ${OPENCV_VERSION}
#
# build opencv debian pacakges from source.
# the generated .deb files will be found in assets/*.deb .
# they will install opencv in /usr/local so it will not conflict with native ubuntu
# opencv installed version and will receive precedence with ld when loading opencv libraries
#
RUN cd opencv && \
mkdir assets && \
cd assets && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr \
-D OPENCV_EXTRA_MODULES_PATH=/home/opencv_contrib/modules \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-D WITH_OPENCL=OFF \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN=5.3 \
-D CUDA_ARCH_PTX="" \
-D WITH_CUDNN=ON \
-D WITH_CUBLAS=ON \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_NEON=ON \
-D WITH_QT=OFF \
-D WITH_OPENMP=ON \
-D BUILD_TIFF=ON \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D BUILD_opencv_python3=ON \
-D WITH_TBB=ON \
-D BUILD_TBB=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D WITH_EIGEN=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_PROTOBUF=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D PYTHON3_EXECUTABLE=/usr/bin/python${PYTHON_VERSION} \
-D PYTHON3_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython${PYTHON_VERSION}.so \
-D PYTHON3_INCLUDE_DIR=/usr/include/python${PYTHON_VERSION} \
-D PYTHON3_PACKAGES_PATH=/usr/local/lib/python${PYTHON_VERSION}//dist-packages \
-D OPENCV_PYTHON3_INSTALL_PATH=/usr/local/lib/python${PYTHON_VERSION}/dist-packages \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D CPACK_BINARY_DEB=ON \
-D CPACK_SET_DESTDIR=OFF \
-D CPACK_PACKAGING_INSTALL_PREFIX=/usr/local ..
RUN cd opencv/assets && make -j$(nproc)
RUN cd opencv/assets && make install
RUN cd opencv/assets && make package
WORKDIR /home/opencv/assets
CMD ["bash", "-c", "cp -r *.deb /home/assets/"]