mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
working odroid build, still needs hwaccel
This commit is contained in:
parent
e791d6646b
commit
228d5ed9c1
118
Dockerfile
118
Dockerfile
@ -1,70 +1,59 @@
|
|||||||
FROM ubuntu:16.04
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
# Install system packages
|
# Install packages for apt repo
|
||||||
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y python3 \
|
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
||||||
python3-dev \
|
apt-transport-https \
|
||||||
python-pil \
|
ca-certificates \
|
||||||
python-lxml \
|
curl \
|
||||||
python-tk \
|
wget \
|
||||||
|
gnupg-agent \
|
||||||
|
dirmngr \
|
||||||
|
software-properties-common
|
||||||
|
|
||||||
|
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D986B59D
|
||||||
|
|
||||||
|
RUN echo "deb http://deb.odroid.in/5422-s bionic main" > /etc/apt/sources.list.d/odroid.list
|
||||||
|
|
||||||
|
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
||||||
|
python3 \
|
||||||
|
# OpenCV dependencies
|
||||||
|
ffmpeg \
|
||||||
build-essential \
|
build-essential \
|
||||||
cmake \
|
cmake \
|
||||||
git \
|
unzip \
|
||||||
libgtk2.0-dev \
|
|
||||||
pkg-config \
|
pkg-config \
|
||||||
libavcodec-dev \
|
|
||||||
libavformat-dev \
|
|
||||||
libswscale-dev \
|
|
||||||
libtbb2 \
|
|
||||||
libtbb-dev \
|
|
||||||
libjpeg-dev \
|
libjpeg-dev \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
libtiff-dev \
|
libtiff-dev \
|
||||||
libjasper-dev \
|
libavcodec-dev \
|
||||||
libdc1394-22-dev \
|
libavformat-dev \
|
||||||
x11-apps \
|
libswscale-dev \
|
||||||
wget \
|
libv4l-dev \
|
||||||
vim \
|
libxvidcore-dev \
|
||||||
ffmpeg \
|
libx264-dev \
|
||||||
unzip \
|
libgtk-3-dev \
|
||||||
libusb-1.0-0-dev \
|
libatlas-base-dev \
|
||||||
python3-setuptools \
|
gfortran \
|
||||||
|
python3-dev \
|
||||||
|
# Coral USB Python API Dependencies
|
||||||
|
libusb-1.0-0 \
|
||||||
|
python3-pip \
|
||||||
|
python3-pil \
|
||||||
python3-numpy \
|
python3-numpy \
|
||||||
zlib1g-dev \
|
libc++1 \
|
||||||
libgoogle-glog-dev \
|
libc++abi1 \
|
||||||
swig \
|
libunwind8 \
|
||||||
libunwind-dev \
|
libgcc1 \
|
||||||
libc++-dev \
|
|
||||||
libc++abi-dev \
|
|
||||||
build-essential \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install core packages
|
# 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 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 \
|
RUN pip install -U pip \
|
||||||
numpy \
|
numpy \
|
||||||
pillow \
|
|
||||||
matplotlib \
|
|
||||||
notebook \
|
|
||||||
Flask \
|
Flask \
|
||||||
imutils \
|
|
||||||
paho-mqtt \
|
paho-mqtt \
|
||||||
PyYAML
|
PyYAML
|
||||||
|
|
||||||
# Install tensorflow models object detection
|
|
||||||
RUN GIT_SSL_NO_VERIFY=true git clone -q https://github.com/tensorflow/models /usr/local/lib/python3.5/dist-packages/tensorflow/models
|
|
||||||
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-python-3.5.1.tar.gz
|
|
||||||
|
|
||||||
# Download & build protobuf-python
|
|
||||||
RUN cd /usr/local/src/ \
|
|
||||||
&& tar xf protobuf-python-3.5.1.tar.gz \
|
|
||||||
&& rm protobuf-python-3.5.1.tar.gz \
|
|
||||||
&& cd /usr/local/src/protobuf-3.5.1/ \
|
|
||||||
&& ./configure \
|
|
||||||
&& make \
|
|
||||||
&& make install \
|
|
||||||
&& ldconfig \
|
|
||||||
&& rm -rf /usr/local/src/protobuf-3.5.1/
|
|
||||||
|
|
||||||
# Download & build OpenCV
|
# Download & build OpenCV
|
||||||
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
|
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
|
||||||
RUN cd /usr/local/src/ \
|
RUN cd /usr/local/src/ \
|
||||||
@ -76,30 +65,31 @@ RUN cd /usr/local/src/ \
|
|||||||
&& cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
|
&& cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
|
||||||
&& make -j4 \
|
&& make -j4 \
|
||||||
&& make install \
|
&& make install \
|
||||||
|
&& ldconfig \
|
||||||
&& rm -rf /usr/local/src/opencv-4.0.1
|
&& rm -rf /usr/local/src/opencv-4.0.1
|
||||||
|
|
||||||
# Download and install EdgeTPU libraries
|
# Download and install EdgeTPU libraries for Coral
|
||||||
RUN wget -q -O edgetpu_api.tar.gz --no-check-certificate http://storage.googleapis.com/cloud-iot-edge-pretrained-models/edgetpu_api.tar.gz
|
RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
|
||||||
|
|
||||||
RUN tar xzf edgetpu_api.tar.gz \
|
RUN tar xzf edgetpu_api.tar.gz \
|
||||||
&& cd python-tflite-source \
|
&& cd edgetpu_api \
|
||||||
&& cp -p libedgetpu/libedgetpu_x86_64.so /lib/x86_64-linux-gnu/libedgetpu.so \
|
&& cp -p libedgetpu/libedgetpu_arm32.so /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0 \
|
||||||
&& cp edgetpu/swig/compiled_so/_edgetpu_cpp_wrapper_x86_64.so edgetpu/swig/_edgetpu_cpp_wrapper.so \
|
&& ldconfig \
|
||||||
&& cp edgetpu/swig/compiled_so/edgetpu_cpp_wrapper.py edgetpu/swig/ \
|
&& python3 -m pip install --no-deps "$(ls edgetpu-*-py3-none-any.whl 2>/dev/null)"
|
||||||
&& python3 setup.py develop --user
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# symlink the model and labels
|
||||||
|
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
|
||||||
|
|
||||||
# Minimize image size
|
# Minimize image size
|
||||||
RUN (apt-get autoremove -y; \
|
RUN (apt-get autoremove -y; \
|
||||||
apt-get autoclean -y)
|
apt-get autoclean -y)
|
||||||
|
|
||||||
# symlink the model and labels
|
|
||||||
RUN ln -s /python-tflite-source/edgetpu/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
|
|
||||||
RUN ln -s /python-tflite-source/edgetpu/test_data/coco_labels.txt /label_map.pbtext
|
|
||||||
|
|
||||||
# Set TF object detection available
|
|
||||||
ENV PYTHONPATH "$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/tensorflow/models/research:/usr/local/lib/python3.5/dist-packages/tensorflow/models/research/slim"
|
|
||||||
RUN cd /usr/local/lib/python3.5/dist-packages/tensorflow/models/research && protoc object_detection/protos/*.proto --python_out=.
|
|
||||||
|
|
||||||
WORKDIR /opt/frigate/
|
WORKDIR /opt/frigate/
|
||||||
ADD frigate frigate/
|
ADD frigate frigate/
|
||||||
COPY detect_objects.py .
|
COPY detect_objects.py .
|
||||||
|
@ -2,7 +2,6 @@ import time
|
|||||||
import datetime
|
import datetime
|
||||||
import threading
|
import threading
|
||||||
import cv2
|
import cv2
|
||||||
from object_detection.utils import visualization_utils as vis_util
|
|
||||||
|
|
||||||
class ObjectCleaner(threading.Thread):
|
class ObjectCleaner(threading.Thread):
|
||||||
def __init__(self, objects_parsed, detected_objects):
|
def __init__(self, objects_parsed, detected_objects):
|
||||||
@ -82,15 +81,10 @@ class BestPersonFrame(threading.Thread):
|
|||||||
best_frame = recent_frames[self.best_person['frame_time']]
|
best_frame = recent_frames[self.best_person['frame_time']]
|
||||||
best_frame = cv2.cvtColor(best_frame, cv2.COLOR_BGR2RGB)
|
best_frame = cv2.cvtColor(best_frame, cv2.COLOR_BGR2RGB)
|
||||||
# draw the bounding box on the frame
|
# draw the bounding box on the frame
|
||||||
vis_util.draw_bounding_box_on_image_array(best_frame,
|
color = (255,0,0)
|
||||||
self.best_person['ymin'],
|
cv2.rectangle(best_frame, (self.best_person['xmin'], self.best_person['ymin']),
|
||||||
self.best_person['xmin'],
|
(self.best_person['xmax'], self.best_person['ymax']),
|
||||||
self.best_person['ymax'],
|
color, 2)
|
||||||
self.best_person['xmax'],
|
|
||||||
color='red',
|
|
||||||
thickness=2,
|
|
||||||
display_str_list=["{}: {}%".format(self.best_person['name'],int(self.best_person['score']*100))],
|
|
||||||
use_normalized_coordinates=False)
|
|
||||||
|
|
||||||
# convert back to BGR
|
# convert back to BGR
|
||||||
self.best_frame = cv2.cvtColor(best_frame, cv2.COLOR_RGB2BGR)
|
self.best_frame = cv2.cvtColor(best_frame, cv2.COLOR_RGB2BGR)
|
||||||
|
@ -6,7 +6,6 @@ import threading
|
|||||||
import ctypes
|
import ctypes
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from object_detection.utils import visualization_utils as vis_util
|
|
||||||
from . util import tonumpyarray
|
from . util import tonumpyarray
|
||||||
from . object_detection import FramePrepper
|
from . object_detection import FramePrepper
|
||||||
from . objects import ObjectCleaner, BestPersonFrame
|
from . objects import ObjectCleaner, BestPersonFrame
|
||||||
@ -283,15 +282,10 @@ class Camera:
|
|||||||
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
||||||
# draw the bounding boxes on the screen
|
# draw the bounding boxes on the screen
|
||||||
for obj in detected_objects:
|
for obj in detected_objects:
|
||||||
vis_util.draw_bounding_box_on_image_array(frame,
|
color = (255,0,0)
|
||||||
obj['ymin'],
|
cv2.rectangle(frame, (obj['xmin'], obj['ymin']),
|
||||||
obj['xmin'],
|
(obj['xmax'], obj['ymax']),
|
||||||
obj['ymax'],
|
color, 2)
|
||||||
obj['xmax'],
|
|
||||||
color='red',
|
|
||||||
thickness=2,
|
|
||||||
display_str_list=["{}: {}%".format(obj['name'],int(obj['score']*100))],
|
|
||||||
use_normalized_coordinates=False)
|
|
||||||
|
|
||||||
for region in self.regions:
|
for region in self.regions:
|
||||||
color = (255,255,255)
|
color = (255,255,255)
|
||||||
|
Loading…
Reference in New Issue
Block a user