forked from Github/frigate
Compare commits
5 Commits
odroid
...
v0.2.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56b9c754f5 | ||
|
|
5c4f5ef3f0 | ||
|
|
8c924896c5 | ||
|
|
2c2f0044b9 | ||
|
|
874e9085a7 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ko_fi: blakeblackshear
|
||||
122
Dockerfile
122
Dockerfile
@@ -1,59 +1,70 @@
|
||||
FROM ubuntu:18.04
|
||||
FROM ubuntu:16.04
|
||||
|
||||
# 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 \
|
||||
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 \
|
||||
# Install system packages
|
||||
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y python3 \
|
||||
python3-dev \
|
||||
python-pil \
|
||||
python-lxml \
|
||||
python-tk \
|
||||
build-essential \
|
||||
cmake \
|
||||
unzip \
|
||||
pkg-config \
|
||||
cmake \
|
||||
git \
|
||||
libgtk2.0-dev \
|
||||
pkg-config \
|
||||
libavcodec-dev \
|
||||
libavformat-dev \
|
||||
libswscale-dev \
|
||||
libtbb2 \
|
||||
libtbb-dev \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
libtiff-dev \
|
||||
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 \
|
||||
libjasper-dev \
|
||||
libdc1394-22-dev \
|
||||
x11-apps \
|
||||
wget \
|
||||
vim \
|
||||
ffmpeg \
|
||||
unzip \
|
||||
libusb-1.0-0-dev \
|
||||
python3-setuptools \
|
||||
python3-numpy \
|
||||
libc++1 \
|
||||
libc++abi1 \
|
||||
libunwind8 \
|
||||
libgcc1 \
|
||||
zlib1g-dev \
|
||||
libgoogle-glog-dev \
|
||||
swig \
|
||||
libunwind-dev \
|
||||
libc++-dev \
|
||||
libc++abi-dev \
|
||||
build-essential \
|
||||
&& 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 \
|
||||
pillow \
|
||||
matplotlib \
|
||||
notebook \
|
||||
Flask \
|
||||
imutils \
|
||||
paho-mqtt \
|
||||
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
|
||||
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/ \
|
||||
@@ -65,31 +76,30 @@ RUN cd /usr/local/src/ \
|
||||
&& cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
|
||||
&& make -j4 \
|
||||
&& make install \
|
||||
&& ldconfig \
|
||||
&& rm -rf /usr/local/src/opencv-4.0.1
|
||||
|
||||
# Download and install EdgeTPU libraries for Coral
|
||||
RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
|
||||
# Download and install EdgeTPU libraries
|
||||
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 tar xzf edgetpu_api.tar.gz \
|
||||
&& cd edgetpu_api \
|
||||
&& cp -p libedgetpu/libedgetpu_arm32.so /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0 \
|
||||
&& ldconfig \
|
||||
&& python3 -m pip install --no-deps "$(ls edgetpu-*-py3-none-any.whl 2>/dev/null)"
|
||||
|
||||
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
|
||||
&& cd python-tflite-source \
|
||||
&& cp -p libedgetpu/libedgetpu_x86_64.so /lib/x86_64-linux-gnu/libedgetpu.so \
|
||||
&& cp edgetpu/swig/compiled_so/_edgetpu_cpp_wrapper_x86_64.so edgetpu/swig/_edgetpu_cpp_wrapper.so \
|
||||
&& cp edgetpu/swig/compiled_so/edgetpu_cpp_wrapper.py edgetpu/swig/ \
|
||||
&& python3 setup.py develop --user
|
||||
|
||||
# Minimize image size
|
||||
RUN (apt-get autoremove -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/
|
||||
ADD frigate frigate/
|
||||
COPY detect_objects.py .
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<a href='https://ko-fi.com/P5P7XGO9' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi4.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||
|
||||
# Frigate - Realtime Object Detection for RTSP Cameras
|
||||
**Note:** This version requires the use of a [Google Coral USB Accelerator](https://coral.withgoogle.com/products/accelerator/)
|
||||
|
||||
|
||||
@@ -25,6 +25,15 @@ def main():
|
||||
# connect to mqtt and setup last will
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
print("On connect called")
|
||||
if rc != 0:
|
||||
if rc == 3:
|
||||
print ("MQTT Server unavailable")
|
||||
elif rc == 4:
|
||||
print ("MQTT Bad username or password")
|
||||
elif rc == 5:
|
||||
print ("MQTT Not authorized")
|
||||
else:
|
||||
print ("Unable to connect to MQTT: Connection refused. Error code: " + str(rc))
|
||||
# publish a message to signal that the service is running
|
||||
client.publish(MQTT_TOPIC_PREFIX+'/available', 'online', retain=True)
|
||||
client = mqtt.Client()
|
||||
@@ -87,4 +96,4 @@ def main():
|
||||
camera.join()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
@@ -2,6 +2,7 @@ import time
|
||||
import datetime
|
||||
import threading
|
||||
import cv2
|
||||
from object_detection.utils import visualization_utils as vis_util
|
||||
|
||||
class ObjectCleaner(threading.Thread):
|
||||
def __init__(self, objects_parsed, detected_objects):
|
||||
@@ -81,10 +82,15 @@ class BestPersonFrame(threading.Thread):
|
||||
best_frame = recent_frames[self.best_person['frame_time']]
|
||||
best_frame = cv2.cvtColor(best_frame, cv2.COLOR_BGR2RGB)
|
||||
# draw the bounding box on the frame
|
||||
color = (255,0,0)
|
||||
cv2.rectangle(best_frame, (self.best_person['xmin'], self.best_person['ymin']),
|
||||
(self.best_person['xmax'], self.best_person['ymax']),
|
||||
color, 2)
|
||||
vis_util.draw_bounding_box_on_image_array(best_frame,
|
||||
self.best_person['ymin'],
|
||||
self.best_person['xmin'],
|
||||
self.best_person['ymax'],
|
||||
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
|
||||
self.best_frame = cv2.cvtColor(best_frame, cv2.COLOR_RGB2BGR)
|
||||
|
||||
@@ -6,6 +6,7 @@ import threading
|
||||
import ctypes
|
||||
import multiprocessing as mp
|
||||
import numpy as np
|
||||
from object_detection.utils import visualization_utils as vis_util
|
||||
from . util import tonumpyarray
|
||||
from . object_detection import FramePrepper
|
||||
from . objects import ObjectCleaner, BestPersonFrame
|
||||
@@ -282,10 +283,15 @@ class Camera:
|
||||
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
||||
# draw the bounding boxes on the screen
|
||||
for obj in detected_objects:
|
||||
color = (255,0,0)
|
||||
cv2.rectangle(frame, (obj['xmin'], obj['ymin']),
|
||||
(obj['xmax'], obj['ymax']),
|
||||
color, 2)
|
||||
vis_util.draw_bounding_box_on_image_array(frame,
|
||||
obj['ymin'],
|
||||
obj['xmin'],
|
||||
obj['ymax'],
|
||||
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:
|
||||
color = (255,255,255)
|
||||
|
||||
Reference in New Issue
Block a user