forked from kaakaa/docker-opencv-contrib-python3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
87 lines (80 loc) · 2.67 KB
/
Dockerfile
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
FROM python:3.5
MAINTAINER Samy Coenen <[email protected]>
RUN apt-get update && apt-get install -y build-essential \
cmake \
wget \
git \
unzip \
yasm \
pkg-config \
libjpeg-dev \
libtiff-dev \
libjasper-dev \
libpng-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libatlas-base-dev \
gfortran \
libtbb2 \
libtbb-dev \
libpq-dev \
tesseract-ocr \
tesseract-ocr-dev \
libgtk2.0-dev \
openssh-server \
sshfs \
&& apt-get -y clean all \
&& rm -rf /var/lib/apt/lists/*
RUN pip install numpy livestreamer pillow urllib3 pytesseract
WORKDIR /
# download opencv and opencv_contrib
RUN wget https://github.com/Itseez/opencv/archive/3.1.0.zip -O opencv.zip \
&& unzip opencv.zip \
&& wget https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip -O opencv_contrib.zip \
&& unzip opencv_contrib \
&& mkdir /opencv-3.1.0/cmake_binary
# download and install leptonica for tesseract-ocr
RUN wget http://www.leptonica.com/source/leptonica-1.73.tar.gz \
&& tar xvf leptonica-1.73.tar.gz \
&& cd leptonica-1.73 \
&& ./configure \
&& make -j \
&& make install
# make and install opencv (multicore)
RUN cd /opencv-3.1.0/cmake_binary \
&& Tesseract_INCLUDE_DIR=/usr/include/tesseract \
&& Tesseract_LIBRARY=/usr/lib \
&& cmake -DOPENCV_EXTRA_MODULES_PATH=/opencv_contrib-3.1.0/modules \
-DBUILD_TIFF=ON \
-DBUILD_opencv_java=OFF \
-DWITH_CUDA=OFF \
-DENABLE_AVX=ON \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DBUILD_opencv_python3=ON \
-DCMAKE_INSTALL_PREFIX=$(python3.5 -c "import sys; print(sys.prefix)") \
-DPYTHON_EXECUTABLE=$(which python3.5) \
-DPYTHON_INCLUDE_DIR=$(python3.5 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON_PACKAGES_PATH=$(python3.5 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") .. \
&& make install -j \
&& rm /opencv.zip \
&& rm /opencv_contrib.zip \
&& rm -r /opencv-3.1.0 \
&& rm -r /opencv_contrib-3.1.0 \
&& rm -r /leptonica-1.73.tar.gz
# enable ssh
# disable pam, otherwise instant disconnect due to docker
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config
RUN service ssh start
# add eng trained data
RUN curl -o /usr/share/tesseract-ocr/tessdata/eng.traineddata https://raw.githubusercontent.com/SamyCoenen/docker-opencv-contrib-python3/master/eng.traineddata