2019-05-27 17:17:57 +02:00
|
|
|
FROM ubuntu:18.04
|
2019-01-26 15:02:59 +01:00
|
|
|
|
2019-06-02 14:29:50 +02:00
|
|
|
ARG DEVICE
|
|
|
|
|
2019-05-27 17:17:57 +02:00
|
|
|
# Install packages for apt repo
|
|
|
|
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
|
|
|
apt-transport-https \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
wget \
|
|
|
|
gnupg-agent \
|
|
|
|
dirmngr \
|
2019-06-02 14:29:50 +02:00
|
|
|
software-properties-common \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2019-05-27 17:17:57 +02:00
|
|
|
|
2019-06-02 14:29:50 +02:00
|
|
|
COPY scripts/install_odroid_repo.sh .
|
2019-05-27 17:17:57 +02:00
|
|
|
|
2019-06-02 14:29:50 +02:00
|
|
|
RUN if [ "$DEVICE" = "odroid" ]; then \
|
|
|
|
sh /install_odroid_repo.sh; \
|
|
|
|
fi
|
2019-05-27 17:17:57 +02:00
|
|
|
|
|
|
|
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
|
|
|
python3 \
|
|
|
|
# OpenCV dependencies
|
|
|
|
ffmpeg \
|
2019-01-26 15:02:59 +01:00
|
|
|
build-essential \
|
2019-05-27 17:17:57 +02:00
|
|
|
cmake \
|
|
|
|
unzip \
|
|
|
|
pkg-config \
|
2019-01-26 15:02:59 +01:00
|
|
|
libjpeg-dev \
|
|
|
|
libpng-dev \
|
|
|
|
libtiff-dev \
|
2019-05-27 17:17:57 +02:00
|
|
|
libavcodec-dev \
|
|
|
|
libavformat-dev \
|
|
|
|
libswscale-dev \
|
|
|
|
libv4l-dev \
|
|
|
|
libxvidcore-dev \
|
|
|
|
libx264-dev \
|
|
|
|
libgtk-3-dev \
|
|
|
|
libatlas-base-dev \
|
|
|
|
gfortran \
|
|
|
|
python3-dev \
|
|
|
|
# Coral USB Python API Dependencies
|
|
|
|
libusb-1.0-0 \
|
|
|
|
python3-pip \
|
|
|
|
python3-pil \
|
2019-03-17 15:03:52 +01:00
|
|
|
python3-numpy \
|
2019-05-27 17:17:57 +02:00
|
|
|
libc++1 \
|
|
|
|
libc++abi1 \
|
|
|
|
libunwind8 \
|
|
|
|
libgcc1 \
|
2019-01-26 15:02:59 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Install core packages
|
|
|
|
RUN wget -q -O /tmp/get-pip.py --no-check-certificate https://bootstrap.pypa.io/get-pip.py && python3 /tmp/get-pip.py
|
|
|
|
RUN pip install -U pip \
|
|
|
|
numpy \
|
2019-02-10 03:37:46 +01:00
|
|
|
Flask \
|
2019-03-28 13:30:58 +01:00
|
|
|
paho-mqtt \
|
2019-06-02 14:29:50 +02:00
|
|
|
PyYAML
|
2019-01-26 15:02:59 +01:00
|
|
|
|
|
|
|
# Download & build OpenCV
|
2019-06-02 14:29:50 +02:00
|
|
|
# TODO: use multistage build to reduce image size:
|
|
|
|
# https://medium.com/@denismakogon/pain-and-gain-running-opencv-application-with-golang-and-docker-on-alpine-3-7-435aa11c7aec
|
|
|
|
# https://www.merixstudio.com/blog/docker-multi-stage-builds-python-development/
|
2019-02-09 14:23:18 +01:00
|
|
|
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
|
2019-01-26 15:02:59 +01:00
|
|
|
RUN cd /usr/local/src/ \
|
2019-02-09 14:23:18 +01:00
|
|
|
&& unzip 4.0.1.zip \
|
|
|
|
&& rm 4.0.1.zip \
|
|
|
|
&& cd /usr/local/src/opencv-4.0.1/ \
|
2019-01-26 15:02:59 +01:00
|
|
|
&& mkdir build \
|
2019-02-09 14:23:18 +01:00
|
|
|
&& cd /usr/local/src/opencv-4.0.1/build \
|
2019-01-26 15:02:59 +01:00
|
|
|
&& cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
|
|
|
|
&& make -j4 \
|
|
|
|
&& make install \
|
2019-05-27 17:17:57 +02:00
|
|
|
&& ldconfig \
|
2019-02-09 14:23:18 +01:00
|
|
|
&& rm -rf /usr/local/src/opencv-4.0.1
|
2019-01-26 15:02:59 +01:00
|
|
|
|
2019-05-27 17:17:57 +02:00
|
|
|
# Download and install EdgeTPU libraries for Coral
|
2019-06-02 14:29:50 +02:00
|
|
|
RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names \
|
|
|
|
&& tar xzf edgetpu_api.tar.gz
|
|
|
|
|
|
|
|
COPY scripts/install_edgetpu_api.sh edgetpu_api/install.sh
|
2019-03-17 15:03:52 +01:00
|
|
|
|
2019-06-02 14:29:50 +02:00
|
|
|
RUN cd edgetpu_api \
|
|
|
|
&& /bin/bash install.sh
|
2019-03-17 15:03:52 +01:00
|
|
|
|
2019-06-02 14:29:50 +02:00
|
|
|
# Copy a python 3.6 version
|
2019-05-27 17:17:57 +02:00
|
|
|
RUN cd /usr/local/lib/python3.6/dist-packages/edgetpu/swig/ \
|
|
|
|
&& ln -s _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-36m-arm-linux-gnueabihf.so
|
2019-01-26 15:02:59 +01:00
|
|
|
|
2019-03-30 13:58:31 +01:00
|
|
|
# symlink the model and labels
|
2019-05-27 17:17:57 +02:00
|
|
|
RUN wget https://dl.google.com/coral/canned_models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite -O mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --trust-server-names
|
|
|
|
RUN wget https://dl.google.com/coral/canned_models/coco_labels.txt -O coco_labels.txt --trust-server-names
|
|
|
|
RUN ln -s mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
|
|
|
|
RUN ln -s /coco_labels.txt /label_map.pbtext
|
2019-03-30 13:58:31 +01:00
|
|
|
|
2019-05-27 17:17:57 +02:00
|
|
|
# Minimize image size
|
|
|
|
RUN (apt-get autoremove -y; \
|
|
|
|
apt-get autoclean -y)
|
2019-01-26 15:02:59 +01:00
|
|
|
|
2019-02-28 13:49:27 +01:00
|
|
|
WORKDIR /opt/frigate/
|
|
|
|
ADD frigate frigate/
|
2019-01-26 15:02:59 +01:00
|
|
|
COPY detect_objects.py .
|
|
|
|
|
2019-03-17 15:03:52 +01:00
|
|
|
CMD ["python3", "-u", "detect_objects.py"]
|