Recently I started working with Docker, I succeeded in building some images for the purpose of running my python script which uses OpenCV.
Now for the next step, I want to deploy these images on my Raspberry Pi3B+, but I failed in building them on the Pi. I've also tried pushing the image which I build successfully on my Ubuntu laptop then go on to Pi and pull the image to run container from it, but it didn't work either.
I found the reason is that all I did was trying to use a amd64 arch (my laptop) image on armv7 arch (my Pi) so that causes some kind of conflict.
I then tried some base images on Docker Hub which were created for armv7, for example: arm32v7/python:3.6, and here's my Dockerfile:
FROM arm32v7/python:3.6
RUN apt-get -y update && apt-get -y upgrade \
&& apt-get install -y python3-pip \
python3-numpy \
libblas-dev \
liblapack-dev \
python3-dev \
libatlas-base-dev \
gfortran \
python3-setuptools \
python3-scipy \
&& apt-get -y update \
&& apt-get -y install python3-h5py \
libsm6 \
libxext6 \
libxrender-dev
RUN pip3 install scipy \
cython \
keras \
opencv-python \
scikit-image
COPY cut.py detect.py c9_0_04_46_23_0.jpg /opt/
COPY MODEL /opt/MODEL
RUN mkdir -p /opt/anh_cut
WORKDIR /opt/
ENTRYPOINT ["python3", "cut.py"]
An error occurred at OpenCV installation step:
Could not find a version that satisfies the requirement opencv-python
I also tried to replace pip config
with:
[global]
extra-index-url=https://www.piwheels.org/simple
which is a repository of precompiled packages for arm architecture, but the same problem still occurred.
Is there any way for me to work around this problem? If not, can I just cross compile OpenCV on my laptop then copy to Dockerfile ? It would be nice if I could have some document to follow, thanks.