Debian 10 (buster) Python 3.10.4 OpenCV 4.1.2
#!/bin/bash
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=2048/g' /etc/dphys-swapfile sudo /etc/init.d/dphys-swapfile stop sudo /etc/init.d/dphys-swapfile start
docker build .
FROM balenalib/raspberrypi3-debian:buster-build
RUN cwd=$(pwd)
RUN apt-get update && apt-get install -y --no-install-recommends
# to build and install
unzip
build-essential cmake pkg-config
checkinstall yasm
# to work with images
libjpeg-dev libtiff-dev libjasper-dev libpng12-dev libtiff5-dev
# to work with videos
libavcodec-dev libavformat-dev libswscale-dev
libxine2-dev libv4l-dev
RUN cd /usr/include/linux &&
sudo ln -s -f ../libv4l1-videodev.h videodev.h &&
cd $cwd
RUN apt-get install -y --no-install-recommends
libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
# needed by highgui tool
libgtk2.0-dev
# for opencv math operations
libatlas-base-dev gfortran
# others
libtbb2 libtbb-dev qt5-default
libmp3lame-dev libtheora-dev
libvorbis-dev libxvidcore-dev libx264-dev
libopencore-amrnb-dev libopencore-amrwb-dev
libavresample-dev
x264 v4l-utils
# cleanup
&& rm -rf /var/lib/apt/lists/*
&& apt-get -y autoremove
RUN pip install --no-cache-dir
# OpenCV dependency
numpy
# other usefull stuff
ipython
# cleanup
&& find /usr/local
( -type d -a -name test -o -name tests )
-o ( -type f -a -name '.pyc' -o -name '.pyo' )
-exec rm -rf '{}' +
&& cd /
&& rm -rf /usr/src/python ~/.cache
ARG OPENCV_VERSION=4.1.2
RUN mkdir opencv && cd opencv
&& wget -O opencv.zip https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip
&& wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip
&& unzip opencv.zip
&& unzip opencv_contrib.zip
&& rm -rf opencv.zip
&& rm -rf opencv_contrib.zip
RUN cd opencv/opencv-${OPENCV_VERSION} && mkdir build && cd build
&& cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules
-D OPENCV_PYTHON3_INSTALL_PATH=/usr/local/lib/python3.10/site-packages/
-D ENABLE_NEON=ON
-D ENABLE_VFPV3=ON
-D BUILD_TESTS=OFF
-D OPENCV_ENABLE_NONFREE=ON
-D INSTALL_PYTHON_EXAMPLES=OFF
-D BUILD_EXAMPLES=OFF ..
RUN cd opencv/opencv-4.1.2/build
&& make
RUN cd opencv/opencv-4.1.2/build
&& make install
RUN cd opencv/opencv-4.1.2/build
&& ldconfig
Content type
Image
Digest
Size
864.1 MB
Last updated
over 4 years ago
docker pull sipeom/rpi3python3opencv4