Installing opencv in a docker container
I am trying to install opencv for this project. In the original dockerfile, they did not provide instructions for installing opencv. The docker part of the file is as follows:
FROM python:3.4-slim
#RUN apt-get -y update
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
gfortran \
git \
libatlas-base-dev \
libav-tools \
libgtk2.0-dev \
libjasper-dev \
libjpeg-dev \
libopencv-dev \
libpng-dev \
libtiff-dev \
libvtk6-dev \
pkg-config \
python-dev \
python-numpy \
python-opencv \
python-pycurl \
qt5-default \
unzip \
webp \
wget \
zlib1g-dev
#&& apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN mkdir -p ~/opencv cd ~/opencv && \
wget https://github.com/Itseez/opencv/archive/3.2.0.zip && \
unzip 3.2.0.zip && \
rm 3.2.0.zip && \
cd opencv-3.2.0 && \
mkdir build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON .. && \
make -j4 && \
make install && \
ldconfig
RUN ln -s /usr/local/lib/python3.4/site-packages/cv2.cpython-34m.so /usr/local/lib/python3.4/site-packages/cv2.so
RUN apt-get -y update
RUN apt-get install -y --fix-missing \
build-essential \
cmake \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-dev \
libavcodec-dev \
libavformat-dev \
libboost-all-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
software-properties-common \
zip \
&& apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN cd ~ && \
mkdir -p dlib && \
git clone -b 'v19.4' --single-branch https://github.com/davisking/dlib.git dlib/ && \
cd dlib/ && \
python3 setup.py install --yes USE_AVX_INSTRUCTIONS
But when I do import cv2
it gives me an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'cv2'
When I do find / -name "cv.py"
I get
/usr/lib/python2.7/dist-packages/cv.py
And for this the find / -name "cv2.so"
result
/usr/local/lib/python3.4/site-packages/cv2.so
/usr/local/lib/python2.7/dist-packages/cv2.so
/opencv-3.2.0/build/lib/cv2.so
I don't know where I am making the mistake. Can anyone please guide me?
Thank!
+3
source to share
No one has answered this question yet
Check out similar questions: