Bläddra i källkod

allow setting the camera fps if needed

Blake Blackshear 4 år sedan
förälder
incheckning
69406343ee
4 ändrade filer med 15 tillägg och 2 borttagningar
  1. 8 0
      config/config.example.yml
  2. 2 0
      detect_objects.py
  3. 2 0
      frigate/edgetpu.py
  4. 3 2
      process_clip.py

+ 8 - 0
config/config.example.yml

@@ -131,6 +131,14 @@ cameras:
     # height: 1280
     # width: 720
 
+    ################
+    ## Specify the framerate of your camera
+    ##
+    ## NOTE: This should only be set in the event ffmpeg is unable to determine your camera's framerate
+    ##       on its own and the reported framerate for your camera in frigate is well over what is expected.
+    ################
+    # fps: 5
+
     ################
     ## Optional mask. Must be the same aspect ratio as your video feed. Value is either the
     ## name of a file in the config directory or a base64 encoded bmp image prefixed with

+ 2 - 0
detect_objects.py

@@ -203,6 +203,8 @@ def main():
         ffmpeg_hwaccel_args = ffmpeg.get('hwaccel_args', FFMPEG_DEFAULT_CONFIG['hwaccel_args'])
         ffmpeg_input_args = ffmpeg.get('input_args', FFMPEG_DEFAULT_CONFIG['input_args'])
         ffmpeg_output_args = ffmpeg.get('output_args', FFMPEG_DEFAULT_CONFIG['output_args'])
+        if not config.get('fps') is None:
+            ffmpeg_output_args = ["-r", str(config.get('fps'))] + ffmpeg_output_args
         if config.get('save_clips', {}).get('enabled', False):
             ffmpeg_output_args = [
                 "-f",

+ 2 - 0
frigate/edgetpu.py

@@ -35,6 +35,7 @@ class ObjectDetector(ABC):
 
 class LocalObjectDetector(ObjectDetector):
     def __init__(self, tf_device=None, labels=None):
+        self.fps = EventsPerSecond()
         if labels is None:
             self.labels = {}
         else:
@@ -83,6 +84,7 @@ class LocalObjectDetector(ObjectDetector):
                 float(d[1]),
                 (d[2], d[3], d[4], d[5])
             ))
+        self.fps.update()
         return detections
 
     def detect_raw(self, tensor_input):

+ 3 - 2
process_clip.py

@@ -42,12 +42,13 @@ class ProcessClip():
 
         object_detector = LocalObjectDetector(labels='/labelmap.txt')
         object_tracker = ObjectTracker(10)
-        process_fps = EventsPerSecond()
+        process_fps = mp.Value('d', 0.0)
+        detection_fps = mp.Value('d', 0.0)
         current_frame = mp.Value('d', 0.0)
         stop_event = mp.Event()
 
         process_frames(self.camera_name, self.frame_queue, self.frame_shape, self.frame_manager, motion_detector, object_detector, object_tracker, self.detected_objects_queue, 
-            process_fps, current_frame, objects_to_track, object_filters, mask, stop_event, exit_on_empty=True)
+            process_fps, detection_fps, current_frame, objects_to_track, object_filters, mask, stop_event, exit_on_empty=True)
     
     def objects_found(self, debug_path=None):
         obj_detected = False