Blake Blackshear 4 سال پیش
والد
کامیت
03c855ecbe
13فایلهای تغییر یافته به همراه77 افزوده شده و 63 حذف شده
  1. 1 0
      frigate/__main__.py
  2. 2 3
      frigate/config.py
  3. 8 7
      frigate/events.py
  4. 2 4
      frigate/http.py
  5. 1 0
      frigate/log.py
  6. 2 1
      frigate/models.py
  7. 2 1
      frigate/motion.py
  8. 3 2
      frigate/mqtt.py
  9. 14 13
      frigate/object_processing.py
  10. 10 7
      frigate/objects.py
  11. 12 10
      frigate/util.py
  12. 19 14
      frigate/video.py
  13. 1 1
      frigate/watchdog.py

+ 1 - 0
frigate/__main__.py

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

+ 2 - 3
frigate/config.py

@@ -1,14 +1,13 @@
 import base64
 import json
 import os
-import yaml
-
 from typing import Dict
 
 import cv2
 import matplotlib.pyplot as plt
 import numpy as np
 import voluptuous as vol
+import yaml
 
 DETECTORS_SCHEMA = vol.Schema(
     {
@@ -593,4 +592,4 @@ class FrigateConfig():
 
     @property
     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 time
-import psutil
+import queue
+import subprocess as sp
 import threading
-import logging
+import time
 from collections import defaultdict
-import json
-import datetime
-import subprocess as sp
-import queue
+
+import psutil
 
 from frigate.models import Event
 

+ 2 - 4
frigate/http.py

@@ -3,10 +3,8 @@ import time
 
 import cv2
 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 playhouse.shortcuts import model_to_dict
 

+ 1 - 0
frigate/log.py

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

+ 2 - 1
frigate/models.py

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

+ 2 - 1
frigate/motion.py

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

+ 3 - 2
frigate/mqtt.py

@@ -1,7 +1,8 @@
 import logging
-import paho.mqtt.client as mqtt
 import threading
 
+import paho.mqtt.client as mqtt
+
 from frigate.config import MqttConfig
 
 logger = logging.getLogger(__name__)
@@ -28,4 +29,4 @@ def create_mqtt_client(config: MqttConfig):
         client.username_pw_set(config.user, password=config.password)
     client.connect(config.host, config.port, 60)
     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 cv2
-import threading
+import datetime
+import hashlib
+import itertools
+import json
 import logging
 import queue
-import copy
-import numpy as np
+import threading
+import time
 from collections import Counter, defaultdict
-import itertools
+from statistics import mean, median
+from typing import Callable, Dict
+
+import cv2
 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 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__)
 

+ 10 - 7
frigate/objects.py

@@ -1,16 +1,19 @@
-import time
+import copy
 import datetime
-import threading
-import cv2
 import itertools
-import copy
-import numpy as np
+import multiprocessing as mp
 import random
 import string
-import multiprocessing as mp
+import threading
+import time
 from collections import defaultdict
+
+import cv2
+import numpy as np
 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():
     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 datetime
+import hashlib
 import json
-import numpy as np
+import signal
 import subprocess as sp
-import cv2
 import threading
-import matplotlib.pyplot as plt
-import hashlib
+import time
+import traceback
+from abc import ABC, abstractmethod
 from multiprocessing import shared_memory
 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'):
     if color is None:
         color = (0,0,255)
@@ -243,4 +245,4 @@ class SharedMemoryFrameManager(FrameManager):
         if name in self.shm_store:
             self.shm_store[name].close()
             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 cv2
-import queue
-import threading
+import itertools
+import json
 import logging
-import ctypes
 import multiprocessing as mp
+import os
+import queue
 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 typing import Dict, List
+
+import cv2
+import numpy as np
+
 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.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__)
 

+ 1 - 1
frigate/watchdog.py

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