update config merging and example config

This commit is contained in:
Blake Blackshear 2020-09-24 07:03:05 -05:00
parent 7c283a1805
commit 2937dac4c3
2 changed files with 4 additions and 10 deletions

View File

@ -78,8 +78,6 @@ save_clips:
objects: objects:
track: track:
- person - person
- car
- truck
filters: filters:
person: person:
min_area: 5000 min_area: 5000
@ -215,11 +213,12 @@ cameras:
draw_zones: False draw_zones: False
################ ################
# Camera level object config. This config is merged with the global config above. # Camera level object config. If defined, this is used instead of the global config.
################ ################
objects: objects:
track: track:
- person - person
- car
filters: filters:
person: person:
min_area: 5000 min_area: 5000

View File

@ -267,13 +267,8 @@ def main():
camera_objects_config = config.get('objects', {}) camera_objects_config = config.get('objects', {})
# get objects to track for camera # get objects to track for camera
objects_to_track = camera_objects_config.get('track', GLOBAL_OBJECT_CONFIG.get('track', ['person'])) objects_to_track = camera_objects_config.get('track', GLOBAL_OBJECT_CONFIG.get('track', ['person']))
# merge object filters # get object filters
global_object_filters = GLOBAL_OBJECT_CONFIG.get('filters', {}) object_filters = camera_objects_config.get('filters', GLOBAL_OBJECT_CONFIG.get('filters', {}))
camera_object_filters = camera_objects_config.get('filters', {})
objects_with_config = set().union(global_object_filters.keys(), camera_object_filters.keys())
object_filters = {}
for obj in objects_with_config:
object_filters[obj] = {**global_object_filters.get(obj, {}), **camera_object_filters.get(obj, {})}
config['objects'] = { config['objects'] = {
'track': objects_to_track, 'track': objects_to_track,
'filters': object_filters 'filters': object_filters