Skip to content

Instantly share code, notes, and snippets.

@ricardodeazambuja
Last active June 19, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardodeazambuja/9bb85f656a0e935ff3d819d65268e5f9 to your computer and use it in GitHub Desktop.
Save ricardodeazambuja/9bb85f656a0e935ff3d819d65268e5f9 to your computer and use it in GitHub Desktop.
Alpine for RPI Zero with Python3 / Numpy / Scipy / OpenCV 4... (WORK IN PROGRESS!!!)
FROM arm32v6/alpine
RUN apk add --update --no-cache \
build-base \
unzip \
wget \
cmake \
# A C language family front-end for LLVM (development files)
clang-dev \
linux-headers
ENV OPENCV_VERSION=4.1.0
#ENV OPENCV_VERSION=3.3.0
RUN cd /opt && \
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
unzip ${OPENCV_VERSION}.zip && \
rm -rf ${OPENCV_VERSION}.zip
# opencv_contrib
RUN cd /opt && \
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
unzip ${OPENCV_VERSION}.zip && \
rm -rf ${OPENCV_VERSION}.zip
RUN apk add --update --no-cache \
# --virtual .build-deps \
#Intel® TBB, a widely used C++ template library for task parallelism'
#libtbb \
#libtbb-dev \
# Wrapper for libjpeg-turbo
libjpeg \
# accelerated baseline JPEG compression and decompression library
libjpeg-turbo-dev \
# Portable Network Graphics library
libpng-dev \
# A software-based implementation of the codec specified in the emerging JPEG-2000 Part-1 standard (development files)
jasper-dev \
# Provides support for the Tag Image File Format or TIFF (development files)
tiff-dev \
# Libraries for working with WebP images (development files)
libwebp-dev \
#
v4l-utils-dev \
tiff-dev \
ffmpeg-dev \
ffmpeg-libs \
v4l-utils-libs \
xvidcore-dev \
x264-dev \
python3 \
python3-dev \
# Using pip actually compiles from source!
# RUN pip3 install --no-cache-dir numpy scipy
py3-numpy \
py3-scipy \
eigen-dev \
openblas-dev \
gfortran \
# gstreamer-dev \ # tried gstreamer and gstreamer-dev, but cmake can't find it...
protobuf-dev \
# keeps giving me seg fault...
protobuf \
ccache
ENV CC /usr/bin/clang
ENV CXX /usr/bin/clang++
RUN mkdir -p /opt/opencv-${OPENCV_VERSION}/build && \
cd /opt/opencv-${OPENCV_VERSION}/build && \
cmake \
-D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_FFMPEG=ON \
-D WITH_IPP=NO \
-D WITH_OPENEXR=NO \
-D WITH_OPENGLES=ON \
# RPI ZERO doesn't has full OPENGL, but OPENGLES.
-D ENABLE_NEON=NO \
-D ENABLE_VFPV3=NO \
# RPI ZERO doesn't has NEON or VFPV3
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_QT=OFF \
-D WITH_GTK=OFF \
-D WITH_CUDA=OFF \
-D BUILD_opencv_java=OFF \
-D WITH_TBB=NO \
-D BUILD_EXAMPLES=NO \
-D BUILD_ANDROID_EXAMPLES=NO \
-D INSTALL_PYTHON_EXAMPLES=NO \
-D BUILD_DOCS=NO \
-D BUILD_opencv_python2=NO \
-D BUILD_opencv_python3=ON \
# Protobuf was generating seg faults
-D BUILD_PROTOBUF=OFF \
-D PROTOBUF_UPDATE_FILES=ON \
-D WITH_GSTREAMER=OFF \
-D BUILD_JAVA=NO \
# ADE was always failing to compile...
-D BUILD_opencv_gapi=OFF \
-D WITH_ADE=OFF \
# All the things below will be automatically found...
# -D PYTHON3_EXECUTABLE=/usr/local/bin/python \
# -D PYTHON3_INCLUDE_DIR=/usr/local/include/python3.6m/ \
# -D PYTHON3_LIBRARY=/usr/local/lib/libpython3.so \
# -D PYTHON_LIBRARY=/usr/local/lib/libpython3.so \
# -D PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.6/site-packages/ \
# -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.6/site-packages/numpy/core/include/ \
.. && \
# make VERBOSE=1 && \
make && \
make install && \
ldconfig \
rm -rf /opt/opencv-${OPENCV_VERSION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment