在docker container

时间:2017-06-28 15:51:00

标签: opencv docker

我正在尝试为this项目安装opencv。在原始的dockerfile中,他们没有给出安装opencv的说明。 dockerfile部分如下:

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

但是当我正在import cv2时,它会给我错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'cv2'

当我正在find / -name "cv.py"时,我正在

  

/usr/lib/python2.7/dist-packages/cv.py

对于此find / -name "cv2.so",结果为

  

/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

我不知道我在哪里弄错了。有人可以指导我吗?

谢谢!

0 个答案:

没有答案