Blake Blackshear 4 年 前
コミット
03c855ecbe

+ 1 - 0
frigate/__main__.py

@@ -1,6 +1,7 @@
 import faulthandler; faulthandler.enable()
 import faulthandler; faulthandler.enable()
 import sys
 import sys
 import threading
 import threading
+
 threading.current_thread().name = "frigate"
 threading.current_thread().name = "frigate"
 
 
 from frigate.app import FrigateApp
 from frigate.app import FrigateApp

+ 2 - 3
frigate/config.py

@@ -1,14 +1,13 @@
 import base64
 import base64
 import json
 import json
 import os
 import os
-import yaml
-
 from typing import Dict
 from typing import Dict
 
 
 import cv2
 import cv2
 import matplotlib.pyplot as plt
 import matplotlib.pyplot as plt
 import numpy as np
 import numpy as np
 import voluptuous as vol
 import voluptuous as vol
+import yaml
 
 
 DETECTORS_SCHEMA = vol.Schema(
 DETECTORS_SCHEMA = vol.Schema(
     {
     {
@@ -593,4 +592,4 @@ class FrigateConfig():
 
 
     @property
     @property
     def cameras(self) -> Dict[str, CameraConfig]:
     def cameras(self) -> Dict[str, CameraConfig]:
-        return self._cameras
+        return self._cameras

+ 8 - 7
frigate/events.py

@@ -1,13 +1,14 @@
+import datetime
+import json
+import logging
 import os
 import os
-import time
-import psutil
+import queue
+import subprocess as sp
 import threading
 import threading
-import logging
+import time
 from collections import defaultdict
 from collections import defaultdict
-import json
-import datetime
-import subprocess as sp
-import queue
+
+import psutil
 
 
 from frigate.models import Event
 from frigate.models import Event
 
 

+ 2 - 4
frigate/http.py

@@ -3,10 +3,8 @@ import time
 
 
 import cv2
 import cv2
 import numpy as np
 import numpy as np
-
-from flask import (
-    Flask, Blueprint, jsonify, request, Response, current_app, make_response
-)
+from flask import (Blueprint, Flask, Response, current_app, jsonify,
+                   make_response, request)
 from peewee import SqliteDatabase
 from peewee import SqliteDatabase
 from playhouse.shortcuts import model_to_dict
 from playhouse.shortcuts import model_to_dict
 
 

+ 1 - 0
frigate/log.py

@@ -3,6 +3,7 @@ import logging
 import threading
 import threading
 from logging import handlers
 from logging import handlers
 
 
+
 def listener_configurer():
 def listener_configurer():
     root = logging.getLogger()
     root = logging.getLogger()
     console_handler = logging.StreamHandler()
     console_handler = logging.StreamHandler()

+ 2 - 1
frigate/models.py

@@ -1,6 +1,7 @@
 from peewee import *
 from peewee import *
 from playhouse.sqlite_ext import *
 from playhouse.sqlite_ext import *
 
 
+
 class Event(Model):
 class Event(Model):
     id = CharField(null=False, primary_key=True, max_length=30)
     id = CharField(null=False, primary_key=True, max_length=30)
     label = CharField(index=True, max_length=20)
     label = CharField(index=True, max_length=20)
@@ -9,4 +10,4 @@ class Event(Model):
     end_time = DateTimeField()
     end_time = DateTimeField()
     top_score = FloatField()
     top_score = FloatField()
     false_positive = BooleanField()
     false_positive = BooleanField()
-    zones = JSONField()
+    zones = JSONField()

+ 2 - 1
frigate/motion.py

@@ -2,6 +2,7 @@ import cv2
 import imutils
 import imutils
 import numpy as np
 import numpy as np
 
 
+
 class MotionDetector():
 class MotionDetector():
     def __init__(self, frame_shape, mask, resize_factor=4):
     def __init__(self, frame_shape, mask, resize_factor=4):
         self.frame_shape = frame_shape
         self.frame_shape = frame_shape
@@ -79,4 +80,4 @@ class MotionDetector():
             cv2.accumulateWeighted(resized_frame, self.avg_frame, 0.2)
             cv2.accumulateWeighted(resized_frame, self.avg_frame, 0.2)
             self.motion_frame_count = 0
             self.motion_frame_count = 0
 
 
-        return motion_boxes
+        return motion_boxes

+ 3 - 2
frigate/mqtt.py

@@ -1,7 +1,8 @@
 import logging
 import logging
-import paho.mqtt.client as mqtt
 import threading
 import threading
 
 
+import paho.mqtt.client as mqtt
+
 from frigate.config import MqttConfig
 from frigate.config import MqttConfig
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)
@@ -28,4 +29,4 @@ def create_mqtt_client(config: MqttConfig):
         client.username_pw_set(config.user, password=config.password)
         client.username_pw_set(config.user, password=config.password)
     client.connect(config.host, config.port, 60)
     client.connect(config.host, config.port, 60)
     client.loop_start()
     client.loop_start()
-    return client
+    return client

+ 14 - 13
frigate/object_processing.py

@@ -1,22 +1,23 @@
-import json
-import hashlib
-import datetime
-import time
 import copy
 import copy
-import cv2
-import threading
+import datetime
+import hashlib
+import itertools
+import json
 import logging
 import logging
 import queue
 import queue
-import copy
-import numpy as np
+import threading
+import time
 from collections import Counter, defaultdict
 from collections import Counter, defaultdict
-import itertools
+from statistics import mean, median
+from typing import Callable, Dict
+
+import cv2
 import matplotlib.pyplot as plt
 import matplotlib.pyplot as plt
-from frigate.util import draw_box_with_label, SharedMemoryFrameManager
-from frigate.edgetpu import load_labels
+import numpy as np
+
 from frigate.config import CameraConfig
 from frigate.config import CameraConfig
-from typing import Callable, Dict
-from statistics import mean, median
+from frigate.edgetpu import load_labels
+from frigate.util import SharedMemoryFrameManager, draw_box_with_label
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)
 
 

+ 10 - 7
frigate/objects.py

@@ -1,16 +1,19 @@
-import time
+import copy
 import datetime
 import datetime
-import threading
-import cv2
 import itertools
 import itertools
-import copy
-import numpy as np
+import multiprocessing as mp
 import random
 import random
 import string
 import string
-import multiprocessing as mp
+import threading
+import time
 from collections import defaultdict
 from collections import defaultdict
+
+import cv2
+import numpy as np
 from scipy.spatial import distance as dist
 from scipy.spatial import distance as dist
-from frigate.util import draw_box_with_label, calculate_region
+
+from frigate.util import calculate_region, draw_box_with_label
+
 
 
 class ObjectTracker():
 class ObjectTracker():
     def __init__(self, max_disappeared):
     def __init__(self, max_disappeared):

+ 12 - 10
frigate/util.py

@@ -1,19 +1,21 @@
-from abc import ABC, abstractmethod
-import datetime
-import time
-import signal
-import traceback
 import collections
 import collections
+import datetime
+import hashlib
 import json
 import json
-import numpy as np
+import signal
 import subprocess as sp
 import subprocess as sp
-import cv2
 import threading
 import threading
-import matplotlib.pyplot as plt
-import hashlib
+import time
+import traceback
+from abc import ABC, abstractmethod
 from multiprocessing import shared_memory
 from multiprocessing import shared_memory
 from typing import AnyStr
 from typing import AnyStr
 
 
+import cv2
+import matplotlib.pyplot as plt
+import numpy as np
+
+
 def draw_box_with_label(frame, x_min, y_min, x_max, y_max, label, info, thickness=2, color=None, position='ul'):
 def draw_box_with_label(frame, x_min, y_min, x_max, y_max, label, info, thickness=2, color=None, position='ul'):
     if color is None:
     if color is None:
         color = (0,0,255)
         color = (0,0,255)
@@ -243,4 +245,4 @@ class SharedMemoryFrameManager(FrameManager):
         if name in self.shm_store:
         if name in self.shm_store:
             self.shm_store[name].close()
             self.shm_store[name].close()
             self.shm_store[name].unlink()
             self.shm_store[name].unlink()
-            del self.shm_store[name]
+            del self.shm_store[name]

+ 19 - 14
frigate/video.py

@@ -1,25 +1,30 @@
-import os
-import time
+import base64
+import copy
+import ctypes
 import datetime
 import datetime
-import cv2
-import queue
-import threading
+import itertools
+import json
 import logging
 import logging
-import ctypes
 import multiprocessing as mp
 import multiprocessing as mp
+import os
+import queue
 import subprocess as sp
 import subprocess as sp
-import numpy as np
-import copy
-import itertools
-import json
-import base64
-from typing import Dict, List
+import threading
+import time
 from collections import defaultdict
 from collections import defaultdict
+from typing import Dict, List
+
+import cv2
+import numpy as np
+
 from frigate.config import CameraConfig
 from frigate.config import CameraConfig
-from frigate.util import draw_box_with_label, yuv_region_2_rgb, area, calculate_region, clipped, intersection_over_union, intersection, EventsPerSecond, listen, FrameManager, SharedMemoryFrameManager
-from frigate.objects import ObjectTracker
 from frigate.edgetpu import RemoteObjectDetector
 from frigate.edgetpu import RemoteObjectDetector
 from frigate.motion import MotionDetector
 from frigate.motion import MotionDetector
+from frigate.objects import ObjectTracker
+from frigate.util import (EventsPerSecond, FrameManager,
+                          SharedMemoryFrameManager, area, calculate_region,
+                          clipped, draw_box_with_label, intersection,
+                          intersection_over_union, listen, yuv_region_2_rgb)
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)
 
 

+ 1 - 1
frigate/watchdog.py

@@ -1,7 +1,7 @@
 import datetime
 import datetime
 import logging
 import logging
-import time
 import threading
 import threading
+import time
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)