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:
track:
- person
- car
- truck
filters:
person:
min_area: 5000
@ -215,11 +213,12 @@ cameras:
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:
track:
- person
- car
filters:
person:
min_area: 5000

View File

@ -267,13 +267,8 @@ def main():
camera_objects_config = config.get('objects', {})
# get objects to track for camera
objects_to_track = camera_objects_config.get('track', GLOBAL_OBJECT_CONFIG.get('track', ['person']))
# merge object filters
global_object_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, {})}
# get object filters
object_filters = camera_objects_config.get('filters', GLOBAL_OBJECT_CONFIG.get('filters', {}))
config['objects'] = {
'track': objects_to_track,
'filters': object_filters