├── .gitignore ├── .dockerignore ├── example ├── app │ └── opencvtest.cpp └── Dockerfile ├── LICENSE ├── README.md └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | log/* 3 | tmp/* 4 | .bundle* 5 | *.jpg 6 | *.mp3 7 | *.mp4 8 | *~ 9 | .idea/ -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | log/* 3 | tmp/* 4 | doc/* 5 | spec/* 6 | *~ 7 | .git/ 8 | .bundle* 9 | .idea/ -------------------------------------------------------------------------------- /example/app/opencvtest.cpp: -------------------------------------------------------------------------------- 1 | #include "opencv2/imgproc/imgproc.hpp" 2 | #include "opencv2/highgui/highgui.hpp" 3 | 4 | using namespace cv; 5 | 6 | int main( int argc, char** argv ) 7 | { 8 | char* imageName = argv[1]; 9 | 10 | Mat image; 11 | image = imread( imageName, 1 ); 12 | 13 | if( argc != 2 || !image.data ) 14 | { 15 | printf( " No image data \n " ); 16 | return -1; 17 | } 18 | 19 | Mat gray_image; 20 | cvtColor( image, gray_image, CV_BGR2GRAY ); 21 | 22 | imwrite( "Gray_Image.jpg", gray_image ); 23 | imshow( "Gray Image", gray_image); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 AmperVue, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-python27-opencv 2 | 3 | 4 | A Docker image running Ubuntu:trusty with Python 2.7, the latest FFMPEG (built from source), and OpenCV 3 (built from source) 5 | 6 | 7 | 8 | ### To Build 9 | 10 | ~~~~ 11 | docker build -t . 12 | ~~~~ 13 | 14 | ### To pull and run from hub.docker.com 15 | 16 | Docker Hub: https://registry.hub.docker.com/u/dkarchmervue/python27-opencv/ 17 | 18 | Source and example: https://github.com/ampervue/docker-python27-opencv 19 | 20 | ~~~~ 21 | docker pull dkarchmervue/python27-opencv 22 | docker run -ti dkarchmervue/python27-opencv bash 23 | ~~~~ 24 | 25 | ### Example 26 | 27 | To demostrate how to use this image, see example/ where another Dockerfile is defined 28 | to demonstrate how to build OpenCV C++ code, and then access it via a VNC Client: 29 | 30 | git clone https://dkarchmer-vue@bitbucket.org/ampervue/python27-opencv.git 31 | cd example 32 | docker build -t opencvtest . 33 | docker run -it --rm -p 5901:5901 -e USER=root opencvtest \ 34 | bash -c "vncserver :1 -geometry 1280x800 -depth 24 && tail -F /root/.vnc/*.log" 35 | 36 | Connect to vnc://:5901 via VNC client. 37 | On a terminal, call program with: `opencvtest sample.jpg` and open generated Gray_Image.jpg -------------------------------------------------------------------------------- /example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dkarchmervue/python27-opencv 2 | 3 | # https://github.com/ampervue/docker-python27-opencv 4 | 5 | MAINTAINER David Karchmer 6 | 7 | # ============================================================================ 8 | # As an example, we compile a small program to load an image and write out 9 | # a gray scale version of it. 10 | # See http://docs.opencv.org/doc/tutorials/introduction/load_save_image/load_save_image.html 11 | # 12 | # ~~~~ 13 | # git clone https://dkarchmer-vue@bitbucket.org/ampervue/python27-opencv.git 14 | # cd example 15 | # docker build -t opencvtest . 16 | # docker run -it --rm -p 5901:5901 -e USER=root opencvtest \ 17 | # bash -c "vncserver :1 -geometry 1280x800 -depth 24 && tail -F /root/.vnc/*.log" 18 | # 19 | # Connect to vnc://:5901 via VNC client. 20 | # On a terminal, call program with: `opencvtest sample.jpg` and open generated Gray_Image.jpg 21 | # ~~~~ 22 | # ============================================================================ 23 | 24 | # Step 0: Install a VNC Server so we can use OpenCV GUI features 25 | # -------------------------------------------------------------- 26 | 27 | # Install VNC server and an editor 28 | RUN apt-get update && \ 29 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 30 | x11-apps \ 31 | firefox \ 32 | lxde-core \ 33 | lxterminal \ 34 | tightvncserver \ 35 | emacs \ 36 | gpicview \ 37 | && rm -rf /var/lib/apt/lists/* 38 | 39 | RUN touch /root/.Xresources 40 | 41 | # Step 1: Install any Python packages 42 | # ---------------------------------------- 43 | 44 | RUN mkdir /code 45 | WORKDIR /code 46 | 47 | # Step 2: Copy code 48 | # ---------------------------------------- 49 | 50 | ADD app /code/app 51 | 52 | # Step 3: Compile Code 53 | # ---------------------------------------- 54 | 55 | WORKDIR /code/app 56 | 57 | RUN g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv` 58 | 59 | # Define default command. 60 | CMD ["bash"] 61 | 62 | # Expose ports. 63 | EXPOSE 5901 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ampervue/python27 2 | 3 | # https://github.com/ampervue/docker-python27-opencv 4 | 5 | MAINTAINER David Karchmer 6 | 7 | ######################################## 8 | # 9 | # Image based on Ubuntu:trusty 10 | # 11 | # with Python 2.7 12 | # and OpenCV 3 (built) 13 | # plus a bunch of build essencials 14 | ####################################### 15 | 16 | ENV OPENCV_VERSION 2.4.10 17 | 18 | WORKDIR /usr/local/src 19 | 20 | RUN git clone --depth 1 https://github.com/l-smash/l-smash \ 21 | && git clone --depth 1 git://git.videolan.org/x264.git \ 22 | && hg clone https://bitbucket.org/multicoreware/x265 \ 23 | && git clone --depth 1 git://source.ffmpeg.org/ffmpeg \ 24 | && git clone https://github.com/Itseez/opencv.git \ 25 | && git clone https://github.com/Itseez/opencv_contrib.git \ 26 | && git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git \ 27 | && git clone --depth 1 https://chromium.googlesource.com/webm/libvpx \ 28 | && git clone https://git.xiph.org/opus.git \ 29 | && git clone --depth 1 https://github.com/mulx/aacgain.git 30 | 31 | # Build L-SMASH 32 | # ================================= 33 | WORKDIR /usr/local/src/l-smash 34 | RUN ./configure 35 | RUN make -j 4 36 | RUN make install 37 | # ================================= 38 | 39 | 40 | # Build libx264 41 | # ================================= 42 | WORKDIR /usr/local/src/x264 43 | RUN ./configure --enable-static 44 | RUN make -j 4 45 | RUN make install 46 | # ================================= 47 | 48 | 49 | # Build libx265 50 | # ================================= 51 | WORKDIR /usr/local/src/x265/build/linux 52 | RUN cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ../../source 53 | RUN make -j 4 54 | RUN make install 55 | # ================================= 56 | 57 | # Build libfdk-aac 58 | # ================================= 59 | WORKDIR /usr/local/src/fdk-aac 60 | RUN autoreconf -fiv 61 | RUN ./configure --disable-shared 62 | RUN make -j 4 63 | RUN make install 64 | # ================================= 65 | 66 | # Build libvpx 67 | # ================================= 68 | WORKDIR /usr/local/src/libvpx 69 | RUN ./configure --disable-examples 70 | RUN make -j 4 71 | RUN make install 72 | # ================================= 73 | 74 | # Build libopus 75 | # ================================= 76 | WORKDIR /usr/local/src/opus 77 | RUN ./autogen.sh 78 | RUN ./configure --disable-shared 79 | RUN make -j 4 80 | RUN make install 81 | # ================================= 82 | 83 | 84 | 85 | # Build OpenCV 3.x 86 | # ================================= 87 | RUN apt-get update -qq && apt-get install -y --force-yes libopencv-dev 88 | RUN pip install --no-cache-dir --upgrade numpy 89 | WORKDIR /usr/local/src 90 | RUN mkdir -p opencv/release 91 | WORKDIR /usr/local/src/opencv/release 92 | RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \ 93 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 94 | -D WITH_TBB=ON \ 95 | -D BUILD_PYTHON_SUPPORT=ON \ 96 | -D WITH_V4L=ON \ 97 | -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ 98 | .. 99 | 100 | RUN make -j4 101 | RUN make install 102 | RUN sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' 103 | RUN ldconfig 104 | # ================================= 105 | 106 | 107 | # Build ffmpeg. 108 | # ================================= 109 | RUN apt-get update -qq && apt-get install -y --force-yes \ 110 | libass-dev 111 | 112 | # --enable-libx265 - Remove until we can debug compile error 113 | WORKDIR /usr/local/src/ffmpeg 114 | RUN ./configure --extra-libs="-ldl" \ 115 | --enable-gpl \ 116 | --enable-libass \ 117 | --enable-libfdk-aac \ 118 | --enable-libfontconfig \ 119 | --enable-libfreetype \ 120 | --enable-libfribidi \ 121 | --enable-libmp3lame \ 122 | --enable-libopus \ 123 | --enable-libtheora \ 124 | --enable-libvorbis \ 125 | --enable-libvpx \ 126 | --enable-libx264 \ 127 | --enable-nonfree 128 | RUN make -j 4 129 | RUN make install 130 | # ================================= 131 | 132 | 133 | # Remove all tmpfile 134 | # ================================= 135 | WORKDIR /usr/local/ 136 | RUN rm -rf /usr/local/src 137 | # ================================= 138 | 139 | --------------------------------------------------------------------------------