mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
update object filters to inherit like motion settings
This commit is contained in:
parent
9451048574
commit
3fab321045
@ -15,6 +15,8 @@ from frigate.util import create_mask
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DEFAULT_TRACKED_OBJECTS = ['person']
|
||||||
|
|
||||||
DETECTORS_SCHEMA = vol.Schema(
|
DETECTORS_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(str): {
|
vol.Required(str): {
|
||||||
@ -111,15 +113,15 @@ DETECT_SCHEMA = vol.Schema(
|
|||||||
FILTER_SCHEMA = vol.Schema(
|
FILTER_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
str: {
|
str: {
|
||||||
vol.Optional('min_area', default=0): int,
|
'min_area': int,
|
||||||
vol.Optional('max_area', default=24000000): int,
|
'max_area': int,
|
||||||
vol.Optional('threshold', default=0.7): float
|
'threshold': float,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def filters_for_all_tracked_objects(object_config):
|
def filters_for_all_tracked_objects(object_config):
|
||||||
for tracked_object in object_config.get('track', ['person']):
|
for tracked_object in object_config.get('track', DEFAULT_TRACKED_OBJECTS):
|
||||||
if not 'filters' in object_config:
|
if not 'filters' in object_config:
|
||||||
object_config['filters'] = {}
|
object_config['filters'] = {}
|
||||||
if not tracked_object in object_config['filters']:
|
if not tracked_object in object_config['filters']:
|
||||||
@ -128,11 +130,11 @@ def filters_for_all_tracked_objects(object_config):
|
|||||||
|
|
||||||
OBJECTS_SCHEMA = vol.Schema(vol.All(filters_for_all_tracked_objects,
|
OBJECTS_SCHEMA = vol.Schema(vol.All(filters_for_all_tracked_objects,
|
||||||
{
|
{
|
||||||
vol.Optional('track', default=['person']): [str],
|
'track': [str],
|
||||||
vol.Optional('filters', default = {}): FILTER_SCHEMA.extend(
|
vol.Optional('filters', default = {}): FILTER_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
str: {
|
str: {
|
||||||
vol.Optional('min_score', default=0.5): float,
|
'min_score': float,
|
||||||
'mask': vol.Any(str, [str]),
|
'mask': vol.Any(str, [str]),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -221,7 +223,7 @@ CAMERAS_SCHEMA = vol.Schema(vol.All(
|
|||||||
vol.Optional('crop', default=True): bool,
|
vol.Optional('crop', default=True): bool,
|
||||||
vol.Optional('height', default=270): int
|
vol.Optional('height', default=270): int
|
||||||
},
|
},
|
||||||
'objects': OBJECTS_SCHEMA,
|
vol.Optional('objects', default={}): OBJECTS_SCHEMA,
|
||||||
vol.Optional('motion', default={}): MOTION_SCHEMA,
|
vol.Optional('motion', default={}): MOTION_SCHEMA,
|
||||||
vol.Optional('detect', default={}): DETECT_SCHEMA.extend({
|
vol.Optional('detect', default={}): DETECT_SCHEMA.extend({
|
||||||
vol.Optional('enabled', default=True): bool
|
vol.Optional('enabled', default=True): bool
|
||||||
@ -504,11 +506,11 @@ class RecordConfig():
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FilterConfig():
|
class FilterConfig():
|
||||||
def __init__(self, config, frame_shape=None):
|
def __init__(self, global_config, config, frame_shape=None):
|
||||||
self._min_area = config['min_area']
|
self._min_area = config.get('min_area', global_config.get('min_area', 0))
|
||||||
self._max_area = config['max_area']
|
self._max_area = config.get('max_area', global_config.get('max_area', 24000000))
|
||||||
self._threshold = config['threshold']
|
self._threshold = config.get('threshold', global_config.get('threshold', 0.7))
|
||||||
self._min_score = config.get('min_score')
|
self._min_score = config.get('min_score', global_config.get('min_score', 0.5))
|
||||||
self._raw_mask = config.get('mask')
|
self._raw_mask = config.get('mask')
|
||||||
self._mask = create_mask(frame_shape, self._raw_mask) if self._raw_mask else None
|
self._mask = create_mask(frame_shape, self._raw_mask) if self._raw_mask else None
|
||||||
|
|
||||||
@ -543,11 +545,8 @@ class FilterConfig():
|
|||||||
|
|
||||||
class ObjectConfig():
|
class ObjectConfig():
|
||||||
def __init__(self, global_config, config, frame_shape):
|
def __init__(self, global_config, config, frame_shape):
|
||||||
self._track = config.get('track', global_config['track'])
|
self._track = config.get('track', global_config.get('track', DEFAULT_TRACKED_OBJECTS))
|
||||||
if 'filters' in config:
|
self._filters = { name: FilterConfig(global_config.get('filters').get(name, {}), config.get('filters').get(name, {}), frame_shape) for name in self._track }
|
||||||
self._filters = { name: FilterConfig(c, frame_shape) for name, c in config['filters'].items() }
|
|
||||||
else:
|
|
||||||
self._filters = { name: FilterConfig(c, frame_shape) for name, c in global_config['filters'].items() }
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def track(self):
|
def track(self):
|
||||||
@ -648,7 +647,7 @@ class CameraClipsConfig():
|
|||||||
self._enabled = config['enabled']
|
self._enabled = config['enabled']
|
||||||
self._pre_capture = config['pre_capture']
|
self._pre_capture = config['pre_capture']
|
||||||
self._post_capture = config['post_capture']
|
self._post_capture = config['post_capture']
|
||||||
self._objects = config.get('objects', global_config['objects']['track'])
|
self._objects = config.get('objects')
|
||||||
self._retain = RetainConfig(global_config['clips']['retain'], config['retain'])
|
self._retain = RetainConfig(global_config['clips']['retain'], config['retain'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -175,7 +175,7 @@ class EventProcessor(threading.Thread):
|
|||||||
|
|
||||||
if not event_data['false_positive']:
|
if not event_data['false_positive']:
|
||||||
clip_created = False
|
clip_created = False
|
||||||
if clips_config.enabled and event_data['label'] in clips_config.objects:
|
if clips_config.enabled and (clips_config.objects is None or event_data['label'] in clips_config.objects):
|
||||||
clip_created = self.create_clip(camera, event_data, clips_config.pre_capture, clips_config.post_capture)
|
clip_created = self.create_clip(camera, event_data, clips_config.pre_capture, clips_config.post_capture)
|
||||||
|
|
||||||
Event.create(
|
Event.create(
|
||||||
|
@ -311,9 +311,7 @@ class TestConfig(TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
config = FrigateConfig(config=config)
|
config = FrigateConfig(config=config)
|
||||||
assert(len(config.cameras['back'].clips.objects) == 2)
|
assert(config.cameras['back'].clips.objects is None)
|
||||||
assert('dog' in config.cameras['back'].clips.objects)
|
|
||||||
assert('person' in config.cameras['back'].clips.objects)
|
|
||||||
|
|
||||||
def test_role_assigned_but_not_enabled(self):
|
def test_role_assigned_but_not_enabled(self):
|
||||||
json_config = {
|
json_config = {
|
||||||
|
Loading…
Reference in New Issue
Block a user