├── LICENSE ├── README.md ├── opencv_3 ├── 3.1.0 │ ├── Dockerfile │ └── download_build_install_opencv.sh ├── 3.4.0 │ ├── Dockerfile │ └── download_build_install_opencv.sh ├── 3.4.1 │ ├── Dockerfile │ └── download_build_install_opencv.sh └── 3.4.2 │ ├── Dockerfile │ └── download_build_install_opencv.sh └── opencv_4 ├── 4.0.0 ├── Dockerfile └── download_build_install_opencv.sh ├── 4.1.0 ├── Dockerfile └── download_build_install_opencv.sh ├── 4.1.1 ├── Dockerfile └── download_build_install_opencv.sh └── 4.1.2 ├── Dockerfile └── download_build_install_opencv.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Mohamed Abdulaziz Ali Haseeb 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker Stars](https://img.shields.io/docker/stars/mohaseeb/raspberrypi3-python-opencv.svg)](https://hub.docker.com/r/mohaseeb/raspberrypi3-python-opencv/) [![Docker Pulls](https://img.shields.io/docker/pulls/mohaseeb/raspberrypi3-python-opencv.svg)](https://hub.docker.com/r/mohaseeb/raspberrypi3-python-opencv/) 2 | 3 | ## About 4 | The Git repo of an [OpenCV](https://opencv.org/) [Docker image](https://hub.docker.com/r/mohaseeb/raspberrypi3-python-opencv/) 5 | , for Raspberry Pi 3 with Raspbian OS (Debian). The modules from OpenCV 6 | contrib are included as well. It is based on [the resin.io python image](https://hub.docker.com/r/resin/raspberrypi3-python/). 7 | 8 | ## Usage 9 | See [the image Docker Hub page](https://hub.docker.com/r/mohaseeb/raspberrypi3-python-opencv/) 10 | for information on how to use the image. 11 | 12 | ## Build 13 | If you prefer to build the image yourself (takes around 2 hours), you can do it as follows: 14 | * Make sure docker is installed in your Raspberry Pi. See [here](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) for 15 | instructions. 16 | * Clone this repository into your Raspberry Pi. 17 | ```commandline 18 | git clone git@github.com:mohaseeb/raspberrypi3-opencv-docker.git 19 | ``` 20 | * Build the image as follows (assumes you want to build the image for OpenvCV 4.1.0): 21 | ```commandline 22 | cd raspberrypi3-opencv-docker/opencv_4/4.1.0/ 23 | docker build -t my_pi_opencv_img . 24 | ``` 25 | * And run it 26 | ```commandline 27 | docker run -it --rm \ 28 | --name my_opencv_app_run \ 29 | my_pi_opencv_img \ 30 | python -c "import cv2; print(cv2.__version__)" 31 | ``` 32 | ## Example 33 | This demonstrates how you can capture video using your Raspberry Pi camera. 34 | * Save the video capturing script to a file named `save_video.py` in your Raspberry Pi. 35 | ```python 36 | # based on https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html#saving-a-video 37 | import cv2 38 | 39 | cap = cv2.VideoCapture(0) 40 | 41 | # Define the codec and create VideoWriter object 42 | fourcc = cv2.VideoWriter_fourcc(*'XVID') 43 | out = cv2.VideoWriter('/videos/output.avi', fourcc, 20.0, (640, 480)) 44 | n_frames = 200 45 | while n_frames > 0: 46 | ret, frame = cap.read() 47 | if ret == True: 48 | # write the flipped frame 49 | out.write(frame) 50 | n_frames -= 1 51 | else: 52 | break 53 | print('frames to capture: {}'.format(n_frames)) 54 | 55 | # Release everything when done 56 | cap.release() 57 | out.release() 58 | ``` 59 | * Execute the script as follows (assumes the camera appears as /dev/vidoe0 on 60 | the Raspberry Pi) 61 | ```bash 62 | # run this from the same directory as your save_video.py script 63 | docker run -it --rm \ 64 | -v `pwd`/save_video.py:/save_video.py \ 65 | -v `pwd`:/videos \ 66 | --device /dev/video0 \ 67 | my_pi_opencv_img \ 68 | python /save_video.py 69 | ``` 70 | * The captured video will be written to file named `output.avi` in the same directory from which the command was executed. 71 | ## References 72 | [OpenCV](https://opencv.org/) 73 |
[Blog post on installing OpenCV 3 on Raspberry Pi](https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/) 74 |
[Blog post on installing OpenCV 4 on Raspberry Pi](https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/) 75 | ## Licence 76 | MIT 77 | -------------------------------------------------------------------------------- /opencv_3/3.1.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | # Install dependencies needed for building and running OpenCV 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | # to build and install 6 | unzip \ 7 | build-essential cmake pkg-config \ 8 | # to work with images 9 | libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \ 10 | # to work with videos 11 | libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ 12 | # needed by highgui tool 13 | libgtk2.0-dev \ 14 | # for opencv math operations 15 | libatlas-base-dev gfortran \ 16 | # cleanup 17 | && rm -rf /var/lib/apt/lists/* \ 18 | && apt-get -y autoremove 19 | 20 | # Install python packages 21 | RUN pip install --no-cache-dir \ 22 | # OpenCV dependency 23 | numpy \ 24 | # other usefull stuff 25 | ipython \ 26 | # cleanup 27 | && find /usr/local \ 28 | \( -type d -a -name test -o -name tests \) \ 29 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 30 | -exec rm -rf '{}' + \ 31 | && cd / \ 32 | && rm -rf /usr/src/python ~/.cache 33 | 34 | # Install OpenCV 35 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 36 | RUN ./download_build_install_opencv.sh 37 | -------------------------------------------------------------------------------- /opencv_3/3.1.0/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=3.1.0 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/Itseez/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D INSTALL_PYTHON_EXAMPLES=ON \ 27 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 28 | .. 29 | 30 | make -j4 31 | 32 | make install 33 | ldconfig 34 | 35 | # verify the installation is successful 36 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 37 | if [ $? -eq 0 ]; then 38 | echo "OpenCV installed successfully! ........................." 39 | else 40 | echo "OpenCV installation failed :( ........................." 41 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 42 | echo "$SITE_PACKAGES_DIR contents: " 43 | echo `ls -ltrh $SITE_PACKAGES_DIR` 44 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 45 | exit 1 46 | fi 47 | 48 | # cleanup 49 | cd $WS_DIR 50 | rm -rf opencv 51 | 52 | -------------------------------------------------------------------------------- /opencv_3/3.4.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | # Install dependencies needed for building and running OpenCV 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | # to build and install 6 | unzip \ 7 | build-essential cmake pkg-config \ 8 | # to work with images 9 | libjpeg-dev libtiff-dev libjasper-dev libpng-dev \ 10 | # to work with videos 11 | libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ 12 | # needed by highgui tool 13 | libgtk2.0-dev \ 14 | # for opencv math operations 15 | libatlas-base-dev gfortran \ 16 | # others 17 | libtbb2 libtbb-dev \ 18 | # cleanup 19 | && rm -rf /var/lib/apt/lists/* \ 20 | && apt-get -y autoremove 21 | 22 | # Install python packages 23 | RUN pip install --no-cache-dir \ 24 | # OpenCV dependency 25 | numpy \ 26 | # other usefull stuff 27 | ipython \ 28 | # cleanup 29 | && find /usr/local \ 30 | \( -type d -a -name test -o -name tests \) \ 31 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 32 | -exec rm -rf '{}' + \ 33 | && cd / \ 34 | && rm -rf /usr/src/python ~/.cache 35 | 36 | # Install OpenCV 37 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 38 | RUN ./download_build_install_opencv.sh 39 | -------------------------------------------------------------------------------- /opencv_3/3.4.0/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=3.4.0 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/Itseez/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | .. 28 | 29 | make -j4 30 | 31 | make install 32 | ldconfig 33 | 34 | # verify the installation is successful 35 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 36 | if [ $? -eq 0 ]; then 37 | echo "OpenCV installed successfully! ........................." 38 | else 39 | echo "OpenCV installation failed :( ........................." 40 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 41 | echo "$SITE_PACKAGES_DIR contents: " 42 | echo `ls -ltrh $SITE_PACKAGES_DIR` 43 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 44 | exit 1 45 | fi 46 | 47 | # cleanup 48 | cd $WS_DIR 49 | rm -rf opencv 50 | 51 | -------------------------------------------------------------------------------- /opencv_3/3.4.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | # Install dependencies needed for building and running OpenCV 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | # to build and install 6 | unzip \ 7 | build-essential cmake pkg-config \ 8 | # to work with images 9 | libjpeg-dev libtiff-dev libjasper-dev libpng-dev \ 10 | # to work with videos 11 | libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ 12 | # needed by highgui tool 13 | libgtk2.0-dev \ 14 | # for opencv math operations 15 | libatlas-base-dev gfortran \ 16 | # others 17 | libtbb2 libtbb-dev \ 18 | # cleanup 19 | && rm -rf /var/lib/apt/lists/* \ 20 | && apt-get -y autoremove 21 | 22 | # Install python packages 23 | RUN pip install --no-cache-dir \ 24 | # OpenCV dependency 25 | numpy \ 26 | # other usefull stuff 27 | ipython \ 28 | # cleanup 29 | && find /usr/local \ 30 | \( -type d -a -name test -o -name tests \) \ 31 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 32 | -exec rm -rf '{}' + \ 33 | && cd / \ 34 | && rm -rf /usr/src/python ~/.cache 35 | 36 | # Install OpenCV 37 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 38 | RUN ./download_build_install_opencv.sh 39 | -------------------------------------------------------------------------------- /opencv_3/3.4.1/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=3.4.1 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | .. 28 | 29 | make -j4 30 | 31 | make install 32 | ldconfig 33 | 34 | # verify the installation is successful 35 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 36 | if [ $? -eq 0 ]; then 37 | echo "OpenCV installed successfully! ........................." 38 | else 39 | echo "OpenCV installation failed :( ........................." 40 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 41 | echo "$SITE_PACKAGES_DIR contents: " 42 | echo `ls -ltrh $SITE_PACKAGES_DIR` 43 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 44 | exit 1 45 | fi 46 | 47 | # cleanup 48 | cd $WS_DIR 49 | rm -rf opencv 50 | 51 | -------------------------------------------------------------------------------- /opencv_3/3.4.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | # Install dependencies needed for building and running OpenCV 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | # to build and install 6 | unzip \ 7 | build-essential cmake pkg-config \ 8 | # to work with images 9 | libjpeg-dev libtiff-dev libjasper-dev libpng-dev \ 10 | # to work with videos 11 | libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ 12 | # needed by highgui tool 13 | libgtk2.0-dev \ 14 | # for opencv math operations 15 | libatlas-base-dev gfortran \ 16 | # others 17 | libtbb2 libtbb-dev \ 18 | # cleanup 19 | && rm -rf /var/lib/apt/lists/* \ 20 | && apt-get -y autoremove 21 | 22 | # Install python packages 23 | RUN pip install --no-cache-dir \ 24 | # OpenCV dependency 25 | numpy \ 26 | # other usefull stuff 27 | ipython \ 28 | # cleanup 29 | && find /usr/local \ 30 | \( -type d -a -name test -o -name tests \) \ 31 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 32 | -exec rm -rf '{}' + \ 33 | && cd / \ 34 | && rm -rf /usr/src/python ~/.cache 35 | 36 | # Install OpenCV 37 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 38 | RUN ./download_build_install_opencv.sh 39 | -------------------------------------------------------------------------------- /opencv_3/3.4.2/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=3.4.2 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | .. 28 | 29 | make -j4 30 | 31 | make install 32 | ldconfig 33 | 34 | # verify the installation is successful 35 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 36 | if [ $? -eq 0 ]; then 37 | echo "OpenCV installed successfully! ........................." 38 | else 39 | echo "OpenCV installation failed :( ........................." 40 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 41 | echo "$SITE_PACKAGES_DIR contents: " 42 | echo `ls -ltrh $SITE_PACKAGES_DIR` 43 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 44 | exit 1 45 | fi 46 | 47 | # cleanup 48 | cd $WS_DIR 49 | rm -rf opencv 50 | 51 | -------------------------------------------------------------------------------- /opencv_4/4.0.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | RUN cwd=$(pwd) 4 | 5 | # Install dependencies needed for building and running OpenCV 6 | RUN apt-get update && apt-get install -y --no-install-recommends \ 7 | # to build and install 8 | unzip \ 9 | build-essential cmake pkg-config \ 10 | checkinstall yasm \ 11 | # to work with images 12 | libjpeg-dev libtiff-dev libjasper-dev libpng12-dev libtiff5-dev \ 13 | # to work with videos 14 | libavcodec-dev libavformat-dev libswscale-dev \ 15 | libxine2-dev libv4l-dev 16 | 17 | RUN cd /usr/include/linux && \ 18 | sudo ln -s -f ../libv4l1-videodev.h videodev.h && \ 19 | cd $cwd 20 | 21 | RUN apt-get install -y --no-install-recommends \ 22 | libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev \ 23 | # needed by highgui tool 24 | libgtk2.0-dev \ 25 | # for opencv math operations 26 | libatlas-base-dev gfortran \ 27 | # others 28 | libtbb2 libtbb-dev qt5-default \ 29 | libmp3lame-dev libtheora-dev \ 30 | libvorbis-dev libxvidcore-dev libx264-dev \ 31 | libopencore-amrnb-dev libopencore-amrwb-dev \ 32 | libavresample-dev \ 33 | x264 v4l-utils \ 34 | # cleanup 35 | && rm -rf /var/lib/apt/lists/* \ 36 | && apt-get -y autoremove 37 | 38 | # Install python packages 39 | RUN pip install --no-cache-dir \ 40 | # OpenCV dependency 41 | numpy \ 42 | # other usefull stuff 43 | ipython \ 44 | # cleanup 45 | && find /usr/local \ 46 | \( -type d -a -name test -o -name tests \) \ 47 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 48 | -exec rm -rf '{}' + \ 49 | && cd / \ 50 | && rm -rf /usr/src/python ~/.cache 51 | 52 | # Install OpenCV 53 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 54 | RUN ./download_build_install_opencv.sh 55 | -------------------------------------------------------------------------------- /opencv_4/4.0.0/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=4.0.0 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | -D OPENCV_PYTHON2_INSTALL_PATH=/usr/local/lib/python2.7/site-packages/ \ 28 | .. 29 | 30 | make -j4 31 | 32 | make install 33 | ldconfig 34 | 35 | # verify the installation is successful 36 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 37 | if [ $? -eq 0 ]; then 38 | echo "OpenCV installed successfully! ........................." 39 | else 40 | echo "OpenCV installation failed :( ........................." 41 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 42 | echo "$SITE_PACKAGES_DIR contents: " 43 | echo `ls -ltrh $SITE_PACKAGES_DIR` 44 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 45 | exit 1 46 | fi 47 | 48 | # cleanup 49 | cd $WS_DIR 50 | rm -rf opencv 51 | 52 | -------------------------------------------------------------------------------- /opencv_4/4.1.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | RUN cwd=$(pwd) 4 | 5 | # https://superuser.com/questions/1423486/issue-with-fetching-http-deb-debian-org-debian-dists-jessie-updates-inrelease 6 | RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list 7 | 8 | # Install dependencies needed for building and running OpenCV 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ 10 | # to build and install 11 | unzip \ 12 | build-essential cmake pkg-config \ 13 | checkinstall yasm \ 14 | # to work with images 15 | libjpeg-dev libtiff-dev libjasper-dev libpng12-dev libtiff5-dev \ 16 | # to work with videos 17 | libavcodec-dev libavformat-dev libswscale-dev \ 18 | libxine2-dev libv4l-dev 19 | 20 | RUN cd /usr/include/linux && \ 21 | sudo ln -s -f ../libv4l1-videodev.h videodev.h && \ 22 | cd $cwd 23 | 24 | RUN apt-get install -y --no-install-recommends \ 25 | libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev \ 26 | # needed by highgui tool 27 | libgtk2.0-dev \ 28 | # for opencv math operations 29 | libatlas-base-dev gfortran \ 30 | # others 31 | libtbb2 libtbb-dev qt5-default \ 32 | libmp3lame-dev libtheora-dev \ 33 | libvorbis-dev libxvidcore-dev libx264-dev \ 34 | libopencore-amrnb-dev libopencore-amrwb-dev \ 35 | libavresample-dev \ 36 | x264 v4l-utils \ 37 | # cleanup 38 | && rm -rf /var/lib/apt/lists/* \ 39 | && apt-get -y autoremove 40 | 41 | # Install python packages 42 | RUN pip install --no-cache-dir \ 43 | # OpenCV dependency 44 | numpy \ 45 | # other usefull stuff 46 | ipython \ 47 | # cleanup 48 | && find /usr/local \ 49 | \( -type d -a -name test -o -name tests \) \ 50 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 51 | -exec rm -rf '{}' + \ 52 | && cd / \ 53 | && rm -rf /usr/src/python ~/.cache 54 | 55 | # Install OpenCV 56 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 57 | RUN ./download_build_install_opencv.sh 58 | -------------------------------------------------------------------------------- /opencv_4/4.1.0/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=4.1.0 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | -D OPENCV_PYTHON2_INSTALL_PATH=/usr/local/lib/python2.7/site-packages/ \ 28 | .. 29 | 30 | make -j4 31 | 32 | make install 33 | ldconfig 34 | 35 | # verify the installation is successful 36 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 37 | if [ $? -eq 0 ]; then 38 | echo "OpenCV installed successfully! ........................." 39 | else 40 | echo "OpenCV installation failed :( ........................." 41 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 42 | echo "$SITE_PACKAGES_DIR contents: " 43 | echo `ls -ltrh $SITE_PACKAGES_DIR` 44 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 45 | exit 1 46 | fi 47 | 48 | # cleanup 49 | cd $WS_DIR 50 | rm -rf opencv 51 | 52 | -------------------------------------------------------------------------------- /opencv_4/4.1.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | RUN cwd=$(pwd) 4 | 5 | # https://superuser.com/questions/1423486/issue-with-fetching-http-deb-debian-org-debian-dists-jessie-updates-inrelease 6 | RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list 7 | 8 | # Install dependencies needed for building and running OpenCV 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ 10 | # to build and install 11 | unzip \ 12 | build-essential cmake pkg-config \ 13 | checkinstall yasm \ 14 | # to work with images 15 | libjpeg-dev libtiff-dev libjasper-dev libpng12-dev libtiff5-dev \ 16 | # to work with videos 17 | libavcodec-dev libavformat-dev libswscale-dev \ 18 | libxine2-dev libv4l-dev 19 | 20 | RUN cd /usr/include/linux && \ 21 | sudo ln -s -f ../libv4l1-videodev.h videodev.h && \ 22 | cd $cwd 23 | 24 | RUN apt-get install -y --no-install-recommends \ 25 | libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev \ 26 | # needed by highgui tool 27 | libgtk2.0-dev \ 28 | # for opencv math operations 29 | libatlas-base-dev gfortran \ 30 | # others 31 | libtbb2 libtbb-dev qt5-default \ 32 | libmp3lame-dev libtheora-dev \ 33 | libvorbis-dev libxvidcore-dev libx264-dev \ 34 | libopencore-amrnb-dev libopencore-amrwb-dev \ 35 | libavresample-dev \ 36 | x264 v4l-utils \ 37 | # cleanup 38 | && rm -rf /var/lib/apt/lists/* \ 39 | && apt-get -y autoremove 40 | 41 | # Install python packages 42 | RUN pip install --no-cache-dir \ 43 | # OpenCV dependency 44 | numpy \ 45 | # other usefull stuff 46 | ipython \ 47 | # cleanup 48 | && find /usr/local \ 49 | \( -type d -a -name test -o -name tests \) \ 50 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 51 | -exec rm -rf '{}' + \ 52 | && cd / \ 53 | && rm -rf /usr/src/python ~/.cache 54 | 55 | # Install OpenCV 56 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 57 | RUN ./download_build_install_opencv.sh 58 | -------------------------------------------------------------------------------- /opencv_4/4.1.1/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=4.1.1 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | -D OPENCV_PYTHON2_INSTALL_PATH=/usr/local/lib/python2.7/site-packages/ \ 28 | .. 29 | 30 | make -j4 31 | 32 | make install 33 | ldconfig 34 | 35 | # verify the installation is successful 36 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 37 | if [ $? -eq 0 ]; then 38 | echo "OpenCV installed successfully! ........................." 39 | else 40 | echo "OpenCV installation failed :( ........................." 41 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 42 | echo "$SITE_PACKAGES_DIR contents: " 43 | echo `ls -ltrh $SITE_PACKAGES_DIR` 44 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 45 | exit 1 46 | fi 47 | 48 | # cleanup 49 | cd $WS_DIR 50 | rm -rf opencv 51 | 52 | -------------------------------------------------------------------------------- /opencv_4/4.1.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/raspberrypi3-python:2.7 2 | 3 | RUN cwd=$(pwd) 4 | 5 | # https://superuser.com/questions/1423486/issue-with-fetching-http-deb-debian-org-debian-dists-jessie-updates-inrelease 6 | RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list 7 | 8 | # Install dependencies needed for building and running OpenCV 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ 10 | # to build and install 11 | unzip \ 12 | build-essential cmake pkg-config \ 13 | checkinstall yasm \ 14 | # to work with images 15 | libjpeg-dev libtiff-dev libjasper-dev libpng12-dev libtiff5-dev \ 16 | # to work with videos 17 | libavcodec-dev libavformat-dev libswscale-dev \ 18 | libxine2-dev libv4l-dev 19 | 20 | RUN cd /usr/include/linux && \ 21 | sudo ln -s -f ../libv4l1-videodev.h videodev.h && \ 22 | cd $cwd 23 | 24 | RUN apt-get install -y --no-install-recommends \ 25 | libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev \ 26 | # needed by highgui tool 27 | libgtk2.0-dev \ 28 | # for opencv math operations 29 | libatlas-base-dev gfortran \ 30 | # others 31 | libtbb2 libtbb-dev qt5-default \ 32 | libmp3lame-dev libtheora-dev \ 33 | libvorbis-dev libxvidcore-dev libx264-dev \ 34 | libopencore-amrnb-dev libopencore-amrwb-dev \ 35 | libavresample-dev \ 36 | x264 v4l-utils \ 37 | # cleanup 38 | && rm -rf /var/lib/apt/lists/* \ 39 | && apt-get -y autoremove 40 | 41 | # Install python packages 42 | RUN pip install --no-cache-dir \ 43 | # OpenCV dependency 44 | numpy \ 45 | # other usefull stuff 46 | ipython \ 47 | # cleanup 48 | && find /usr/local \ 49 | \( -type d -a -name test -o -name tests \) \ 50 | -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ 51 | -exec rm -rf '{}' + \ 52 | && cd / \ 53 | && rm -rf /usr/src/python ~/.cache 54 | 55 | # Install OpenCV 56 | COPY download_build_install_opencv.sh download_build_install_opencv.sh 57 | RUN ./download_build_install_opencv.sh 58 | -------------------------------------------------------------------------------- /opencv_4/4.1.2/download_build_install_opencv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OPENCV_VERSION=4.1.2 4 | 5 | WS_DIR=`pwd` 6 | mkdir opencv 7 | cd opencv 8 | 9 | # download OpenCV and opencv_contrib 10 | wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip 11 | unzip opencv.zip 12 | rm -rf opencv.zip 13 | 14 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip 15 | unzip opencv_contrib.zip 16 | rm -rf opencv_contrib.zip 17 | 18 | OPENCV_SRC_DIR=`pwd`/opencv-$OPENCV_VERSION 19 | OPENCV_CONTRIB_MODULES_SRC_DIR=`pwd`/opencv_contrib-$OPENCV_VERSION/modules 20 | 21 | # build and install 22 | cd $OPENCV_SRC_DIR 23 | mkdir build && cd build 24 | cmake -D CMAKE_BUILD_TYPE=RELEASE \ 25 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 26 | -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_MODULES_SRC_DIR \ 27 | -D OPENCV_PYTHON2_INSTALL_PATH=/usr/local/lib/python2.7/site-packages/ \ 28 | .. 29 | 30 | make -j4 31 | 32 | make install 33 | ldconfig 34 | 35 | # verify the installation is successful 36 | python -c "import cv2; print('Installed OpenCV version is: {} :)'.format(cv2.__version__))" 37 | if [ $? -eq 0 ]; then 38 | echo "OpenCV installed successfully! ........................." 39 | else 40 | echo "OpenCV installation failed :( ........................." 41 | SITE_PACKAGES_DIR=/usr/local/lib/python2.7/site-packages 42 | echo "$SITE_PACKAGES_DIR contents: " 43 | echo `ls -ltrh $SITE_PACKAGES_DIR` 44 | echo "Note: temporary installation dir $WS_DIR/opencv is not removed!" 45 | exit 1 46 | fi 47 | 48 | # cleanup 49 | cd $WS_DIR 50 | rm -rf opencv 51 | 52 | --------------------------------------------------------------------------------