Skip to content

Commit

Permalink
allow setting the camera fps if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Sep 17, 2020
1 parent 1c33b8a commit 6940634
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions detect_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def on_connect(client, userdata, flags, rc):
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",
Expand Down
2 changes: 2 additions & 0 deletions frigate/edgetpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def detect(self, tensor_input, threshold = .4):

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

def detect_raw(self, tensor_input):
Expand Down
5 changes: 3 additions & 2 deletions process_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def process_frames(self, objects_to_track=['person'], object_filters={}):

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
Expand Down

0 comments on commit 6940634

Please sign in to comment.