mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +01:00
cleanup
This commit is contained in:
parent
bb8e4621f5
commit
05951aa7da
@ -51,12 +51,6 @@ GLOBAL_OBJECT_CONFIG = CONFIG.get('objects', {})
|
||||
WEB_PORT = CONFIG.get('web_port', 5000)
|
||||
DEBUG = (CONFIG.get('debug', '0') == '1')
|
||||
|
||||
# TODO: make CPU/Coral switching more seamless
|
||||
# MODEL_PATH = CONFIG.get('tflite_model', '/lab/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite')
|
||||
MODEL_PATH = CONFIG.get('tflite_model', '/lab/detect.tflite')
|
||||
LABEL_MAP = CONFIG.get('label_map', '/lab/labelmap.txt')
|
||||
|
||||
|
||||
class CameraWatchdog(threading.Thread):
|
||||
def __init__(self, camera_processes, config, tflite_process, tracked_objects_queue):
|
||||
threading.Thread.__init__(self)
|
||||
@ -129,13 +123,13 @@ def main():
|
||||
tracked_objects_queue = mp.Queue()
|
||||
|
||||
# Start the shared tflite process
|
||||
tflite_process = EdgeTPUProcess(MODEL_PATH)
|
||||
tflite_process = EdgeTPUProcess()
|
||||
|
||||
# start the camera processes
|
||||
camera_processes = {}
|
||||
for name, config in CONFIG['cameras'].items():
|
||||
camera_processes[name] = {
|
||||
'fps': mp.Value('d', float(config[name]['fps'])),
|
||||
'fps': mp.Value('d', float(config['fps'])),
|
||||
'skipped_fps': mp.Value('d', 0.0)
|
||||
}
|
||||
camera_process = mp.Process(target=track_camera, args=(name, config, FFMPEG_DEFAULT_CONFIG, GLOBAL_OBJECT_CONFIG,
|
||||
|
@ -27,7 +27,7 @@ def load_labels(path, encoding='utf-8'):
|
||||
return {index: line.strip() for index, line in enumerate(lines)}
|
||||
|
||||
class ObjectDetector():
|
||||
def __init__(self, model_file):
|
||||
def __init__(self):
|
||||
edge_tpu_delegate = None
|
||||
try:
|
||||
edge_tpu_delegate = load_delegate('libedgetpu.so.1.0')
|
||||
@ -61,7 +61,7 @@ class ObjectDetector():
|
||||
return detections
|
||||
|
||||
class EdgeTPUProcess():
|
||||
def __init__(self, model):
|
||||
def __init__(self):
|
||||
# TODO: see if we can use the plasma store with a queue and maintain the same speeds
|
||||
try:
|
||||
sa.delete("frame")
|
||||
@ -79,11 +79,11 @@ class EdgeTPUProcess():
|
||||
self.detect_ready = mp.Event()
|
||||
self.frame_ready = mp.Event()
|
||||
self.fps = mp.Value('d', 0.0)
|
||||
self.avg_inference_speed = mp.Value('d', 10.0)
|
||||
self.avg_inference_speed = mp.Value('d', 0.01)
|
||||
|
||||
def run_detector(model, detect_ready, frame_ready, fps, avg_speed):
|
||||
def run_detector(detect_ready, frame_ready, fps, avg_speed):
|
||||
print(f"Starting detection process: {os.getpid()}")
|
||||
object_detector = ObjectDetector(model)
|
||||
object_detector = ObjectDetector()
|
||||
input_frame = sa.attach("frame")
|
||||
detections = sa.attach("detections")
|
||||
fps_tracker = EventsPerSecond()
|
||||
@ -103,7 +103,7 @@ class EdgeTPUProcess():
|
||||
duration = datetime.datetime.now().timestamp()-start
|
||||
avg_speed.value = (avg_speed.value*9 + duration)/10
|
||||
|
||||
self.detect_process = mp.Process(target=run_detector, args=(model, self.detect_ready, self.frame_ready, self.fps, self.avg_inference_speed))
|
||||
self.detect_process = mp.Process(target=run_detector, args=(self.detect_ready, self.frame_ready, self.fps, self.avg_inference_speed))
|
||||
self.detect_process.daemon = True
|
||||
self.detect_process.start()
|
||||
|
||||
|
@ -146,7 +146,7 @@ def track_camera(name, config, ffmpeg_global_config, global_objects_config, dete
|
||||
mask[:] = 255
|
||||
|
||||
motion_detector = MotionDetector(frame_shape, mask, resize_factor=6)
|
||||
object_detector = RemoteObjectDetector('/lab/labelmap.txt', detect_lock, detect_ready, frame_ready)
|
||||
object_detector = RemoteObjectDetector('/labelmap.txt', detect_lock, detect_ready, frame_ready)
|
||||
|
||||
object_tracker = ObjectTracker(10)
|
||||
|
||||
@ -193,7 +193,7 @@ def track_camera(name, config, ffmpeg_global_config, global_objects_config, dete
|
||||
motion_boxes = motion_detector.detect(frame)
|
||||
|
||||
# skip object detection if we are below the min_fps
|
||||
if frame_num > 50 and fps.value < expected_fps-1:
|
||||
if frame_num > 100 and fps.value < expected_fps-1:
|
||||
skipped_fps_tracker.update()
|
||||
skipped_fps.value = skipped_fps_tracker.eps()
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user