Dockerfile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. FROM ubuntu:18.04
  2. # Install packages for apt repo
  3. RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
  4. apt-transport-https \
  5. ca-certificates \
  6. curl \
  7. wget \
  8. gnupg-agent \
  9. dirmngr \
  10. software-properties-common
  11. RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D986B59D
  12. RUN echo "deb http://deb.odroid.in/5422-s bionic main" > /etc/apt/sources.list.d/odroid.list
  13. RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
  14. python3 \
  15. # OpenCV dependencies
  16. ffmpeg \
  17. build-essential \
  18. cmake \
  19. unzip \
  20. pkg-config \
  21. libjpeg-dev \
  22. libpng-dev \
  23. libtiff-dev \
  24. libavcodec-dev \
  25. libavformat-dev \
  26. libswscale-dev \
  27. libv4l-dev \
  28. libxvidcore-dev \
  29. libx264-dev \
  30. libgtk-3-dev \
  31. libatlas-base-dev \
  32. gfortran \
  33. python3-dev \
  34. # Coral USB Python API Dependencies
  35. libusb-1.0-0 \
  36. python3-pip \
  37. python3-pil \
  38. python3-numpy \
  39. libc++1 \
  40. libc++abi1 \
  41. libunwind8 \
  42. libgcc1 \
  43. && rm -rf /var/lib/apt/lists/*
  44. # Install core packages
  45. RUN wget -q -O /tmp/get-pip.py --no-check-certificate https://bootstrap.pypa.io/get-pip.py && python3 /tmp/get-pip.py
  46. RUN pip install -U pip \
  47. numpy \
  48. Flask \
  49. paho-mqtt \
  50. PyYAML \
  51. ffmpeg-python
  52. # Download & build OpenCV
  53. RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
  54. RUN cd /usr/local/src/ \
  55. && unzip 4.0.1.zip \
  56. && rm 4.0.1.zip \
  57. && cd /usr/local/src/opencv-4.0.1/ \
  58. && mkdir build \
  59. && cd /usr/local/src/opencv-4.0.1/build \
  60. && cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
  61. && make -j4 \
  62. && make install \
  63. && ldconfig \
  64. && rm -rf /usr/local/src/opencv-4.0.1
  65. # Download and install EdgeTPU libraries for Coral
  66. RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
  67. RUN tar xzf edgetpu_api.tar.gz \
  68. && cd edgetpu_api \
  69. && cp -p libedgetpu/libedgetpu_arm32.so /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0 \
  70. && ldconfig \
  71. && python3 -m pip install --no-deps "$(ls edgetpu-*-py3-none-any.whl 2>/dev/null)"
  72. RUN cd /usr/local/lib/python3.6/dist-packages/edgetpu/swig/ \
  73. && ln -s _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-36m-arm-linux-gnueabihf.so
  74. # symlink the model and labels
  75. 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
  76. RUN wget https://dl.google.com/coral/canned_models/coco_labels.txt -O coco_labels.txt --trust-server-names
  77. RUN ln -s mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
  78. RUN ln -s /coco_labels.txt /label_map.pbtext
  79. # Minimize image size
  80. RUN (apt-get autoremove -y; \
  81. apt-get autoclean -y)
  82. WORKDIR /opt/frigate/
  83. ADD frigate frigate/
  84. COPY detect_objects.py .
  85. CMD ["python3", "-u", "detect_objects.py"]