mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
4383b883c0
* Refactor EdgeTPU and CPU model handling to detector submodules. * Fix selecting the correct detection device type from the config * Remove detector type check when creating ObjectDetectProcess * Fixes after rebasing to 0.11 * Add init file to detector folder * Rename to detect_api Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> * Add unit test for LocalObjectDetector class * Add configuration for model inputs Support transforming detection regions to RGB or BGR. Support specifying the input tensor shape. The tensor shape has a standard format ["BHWC"] when handed to the detector, but can be transformed in the detector to match the model shape using the model input_tensor config. * Add documentation for new model config parameters * Add input tensor transpose to LocalObjectDetector * Change the model input tensor config to use an enumeration * Updates for model config documentation Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
import datetime
|
|
import logging
|
|
import threading
|
|
import time
|
|
import os
|
|
import signal
|
|
|
|
from frigate.object_detection import ObjectDetectProcess
|
|
from frigate.util import restart_frigate
|
|
from multiprocessing.synchronize import Event
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class FrigateWatchdog(threading.Thread):
|
|
def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: Event):
|
|
threading.Thread.__init__(self)
|
|
self.name = "frigate_watchdog"
|
|
self.detectors = detectors
|
|
self.stop_event = stop_event
|
|
|
|
def run(self) -> None:
|
|
time.sleep(10)
|
|
while not self.stop_event.wait(10):
|
|
now = datetime.datetime.now().timestamp()
|
|
|
|
# check the detection processes
|
|
for detector in self.detectors.values():
|
|
detection_start = detector.detection_start.value
|
|
if detection_start > 0.0 and now - detection_start > 10:
|
|
logger.info(
|
|
"Detection appears to be stuck. Restarting detection process..."
|
|
)
|
|
detector.start_or_restart()
|
|
elif (
|
|
detector.detect_process is not None
|
|
and not detector.detect_process.is_alive()
|
|
):
|
|
logger.info("Detection appears to have stopped. Exiting frigate...")
|
|
restart_frigate()
|
|
|
|
logger.info(f"Exiting watchdog...")
|