-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-arm
120 lines (108 loc) · 3.57 KB
/
Dockerfile-arm
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
ARG PYTHON_VERSION_SHORT=3.11
ARG OPENCV_VERSION=4.8.1
ARG CPU_CORES=10
# Download qemu-user-static for amd64
# to build and run on x86_64 (requires binfmt_misc)
FROM ubuntu as x86_64
RUN set -e; \
apt-get update; \
apt-get install -y --no-install-recommends qemu-user-static; \
rm -rf /var/lib/apt/lists/*
FROM --platform=linux/arm64/v8 arm64v8/python:${PYTHON_VERSION_SHORT}
COPY --from=x86_64 /usr/bin/qemu-*-static /usr/bin/
LABEL org.opencontainers.image.source="https://github.com/Ninjineers-2383/docker-opencv"
ARG DEBIAN_FRONTEND=noninteractive
# Installing build tools and dependencies.
# More about dependencies there: https://docs.opencv.org/4.0.0/d2/de6/tutorial_py_setup_in_ubuntu.html
RUN set -e; \
apt-get update; \
apt-get install -y --no-install-recommends \
apt-utils \
build-essential; \
apt-get install -y --no-install-recommends \
# Downloading utils
unzip \
wget \
# Build utils
cmake \
gcc \
# Required dependencies
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libgstreamer-plugins-base1.0-dev \
# Optional dependencies
libjpeg-dev \
libpng-dev \
libopenexr-dev \
libtiff-dev \
libwebp-dev \
# Video device drivers
libv4l-dev \
libdc1394-dev; \
# Clear apt cache
rm -rf /var/lib/apt/lists/*
RUN pip3 install numpy
ARG OPENCV_VERSION
ENV OPENCV_VERSION=$OPENCV_VERSION
# Download latest source and contrib
RUN set -e; \
cd /tmp; \
wget -c -nv -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip; \
unzip opencv.zip; \
wget -c -nv -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip; \
unzip opencv_contrib.zip
ARG PYTHON_VERSION_SHORT
ENV PYTHON_VERSION=$PYTHON_VERSION_SHORT
ARG CPU_CORES
# Build opencv
RUN set -e; \
cd /tmp/opencv-$OPENCV_VERSION; \
mkdir build; \
cd build; \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv_contrib-$OPENCV_VERSION/modules \
-D CMAKE_INSTALL_PREFIX=/usr/local \
# Build without GUI support
-D WITH_QT=OFF \
-D WITH_GTK=OFF \
# Build without GPU support
-D WITH_OPENCL=OFF \
-D WITH_CUDA=OFF \
-D BUILD_opencv_gpu=OFF \
-D BUILD_opencv_gpuarithm=OFF \
-D BUILD_opencv_gpubgsegm=OFF \
-D BUILD_opencv_gpucodec=OFF \
-D BUILD_opencv_gpufeatures2d=OFF \
-D BUILD_opencv_gpufilters=OFF \
-D BUILD_opencv_gpuimgproc=OFF \
-D BUILD_opencv_gpulegacy=OFF \
-D BUILD_opencv_gpuoptflow=OFF \
-D BUILD_opencv_gpustereo=OFF \
-D BUILD_opencv_gpuwarping=OFF \
# Build with gstreamer support
-D WITH_GSTREAMER=ON \
# Build with python
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D OPENCV_PYTHON3_INSTALL_PATH=$(python${PYTHON_VERSION} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$(python${PYTHON_VERSION} -c "import numpy; print(numpy.get_include())") \
# Ignore all unnecessary stages
-D BUILD_opencv_apps=OFF \
-D BUILD_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D ENABLE_CXX11=ON \
..; \
make -j$CPU_CORES; \
make install; \
ldconfig; \
# Clean up
make clean; \
cd /tmp; \
rm -rf /tmp/*
CMD ["/bin/bash"]