-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.armv7hf
129 lines (117 loc) · 4.41 KB
/
Dockerfile.armv7hf
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
121
122
123
124
125
126
127
128
129
ARG PYTHON_VERSION_SHORT=3.7
ARG OPENCV_VERSION=4.3.0
ARG CPU_CORES=4
FROM arm32v7/python:${PYTHON_VERSION_SHORT}-buster
ARG DEBIAN_FRONTEND=noninteractive
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
python-numpy \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libgstreamer-plugins-base1.0-dev \
# Optional dependencies
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libopenexr-dev \
libtiff-dev \
libwebp-dev \
# Video device drivers
libv4l-dev \
libdc1394-22-dev
RUN pip 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 python
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D OPENCV_SKIP_PYTHON_LOADER=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=$(python${PYTHON_VERSION} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
# 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 \
..; \
make -j$CPU_CORES; \
make install; \
ldconfig; \
# Clean up
make clean; \
cd /tmp; \
rm -rf /tmp/*
RUN ln -s /usr/local/lib/python3.7/site-packages/cv2.cpython-37m-arm-linux-gnueabihf.so /usr/local/lib/python3.7/site-packages/cv2.so
# Install dldt
WORKDIR /
RUN apt-get install -y git build-essential curl wget libssl-dev ca-certificates libboost-regex-dev libgtk2.0-dev \
pkg-config automake libtool autoconf libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev \
libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base libusb-1.0-0-dev libopenblas-dev libpng-dev
RUN git clone https://github.com/opencv/dldt.git && cd /dldt/inference-engine && git submodule init && git submodule update --recursive
RUN sed -i -- "s/return std::move(ret);/return ret;/g" /dldt/inference-engine/thirdparty/ade/sources/ade/source/execution_engine.cpp
ENV OpenCV_DIR=/usr/local/share/opencv4
RUN pip3 install cython
RUN cd /dldt && mkdir build && cd build && cmake \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_MKL_DNN=OFF \
-DENABLE_CLDNN=OFF \
-DENABLE_GNA=OFF \
-DENABLE_SSE42=OFF \
-DTHREADING=SEQ \
-DENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=/usr/bin/python3.7 \
-DPYTHON_LIBRARY=/usr/local/lib/libpython3.7m.so \
-DPYTHON_INCLUDE_DIR=/usr/local/include/python3.7m/ .. && make -j$CPU_CORES && make install && cd .. && rm -r build
ENV PYTHONPATH=/dldt/bin/armv7l/Release/lib/python_api/python3.7
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp* /root/.cache/pip/wheels/*