mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Address review comments
- Accept `ratio` default - Rename `bounds` to `box` for consistency - Add migration for new field Issue: #2948
This commit is contained in:
parent
d64329b7df
commit
3bb3aecf97
@ -215,7 +215,7 @@ class FilterConfig(FrigateBaseModel):
|
|||||||
title="Minimum ratio of bounding box's width/height for object to be counted.",
|
title="Minimum ratio of bounding box's width/height for object to be counted.",
|
||||||
)
|
)
|
||||||
max_ratio: float = Field(
|
max_ratio: float = Field(
|
||||||
default=24000000, # @todo: Is there a way to make this `math.inf` but still load from YAML?
|
default=24000000,
|
||||||
title="Maximum ratio of bounding box's width/height for object to be counted.",
|
title="Maximum ratio of bounding box's width/height for object to be counted.",
|
||||||
)
|
)
|
||||||
threshold: float = Field(
|
threshold: float = Field(
|
||||||
|
|||||||
@ -39,7 +39,7 @@ logger = logging.getLogger(__name__)
|
|||||||
def filtered(obj, objects_to_track, object_filters):
|
def filtered(obj, objects_to_track, object_filters):
|
||||||
object_name = obj[0]
|
object_name = obj[0]
|
||||||
object_score = obj[1]
|
object_score = obj[1]
|
||||||
object_bounds = obj[2]
|
object_box = obj[2]
|
||||||
object_area = obj[3]
|
object_area = obj[3]
|
||||||
|
|
||||||
if not object_name in objects_to_track:
|
if not object_name in objects_to_track:
|
||||||
@ -65,9 +65,9 @@ def filtered(obj, objects_to_track, object_filters):
|
|||||||
if not obj_settings.mask is None:
|
if not obj_settings.mask is None:
|
||||||
# compute the coordinates of the object and make sure
|
# compute the coordinates of the object and make sure
|
||||||
# the location isn't outside the bounds of the image (can happen from rounding)
|
# the location isn't outside the bounds of the image (can happen from rounding)
|
||||||
object_xmin = object_bounds[0]
|
object_xmin = object_box[0]
|
||||||
object_xmax = object_bounds[2]
|
object_xmax = object_box[2]
|
||||||
object_ymax = object_bounds[3]
|
object_ymax = object_box[3]
|
||||||
y_location = min(int(object_ymax), len(obj_settings.mask) - 1)
|
y_location = min(int(object_ymax), len(obj_settings.mask) - 1)
|
||||||
x_location = min(
|
x_location = min(
|
||||||
int((object_xmax + object_xmin) / 2.0),
|
int((object_xmax + object_xmin) / 2.0),
|
||||||
@ -626,13 +626,13 @@ def process_frames(
|
|||||||
for group in detected_object_groups.values():
|
for group in detected_object_groups.values():
|
||||||
|
|
||||||
# apply non-maxima suppression to suppress weak, overlapping bounding boxes
|
# apply non-maxima suppression to suppress weak, overlapping bounding boxes
|
||||||
bounds = o[2] # xmin, ymin, xmax, ymax
|
box = o[2] # xmin, ymin, xmax, ymax
|
||||||
boxes = [
|
boxes = [
|
||||||
(
|
(
|
||||||
bounds[0],
|
box[0],
|
||||||
bounds[1],
|
box[1],
|
||||||
bounds[2] - bounds[0],
|
box[2] - box[0],
|
||||||
bounds[3] - bounds[1],
|
box[3] - box[1],
|
||||||
)
|
)
|
||||||
for o in group
|
for o in group
|
||||||
]
|
]
|
||||||
|
|||||||
38
migrations/007_add_object_filter_ratio.py
Normal file
38
migrations/007_add_object_filter_ratio.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
"""Peewee migrations -- 007_add_object_filter_ratio.py.
|
||||||
|
|
||||||
|
Some examples (model - class or model name)::
|
||||||
|
|
||||||
|
> Model = migrator.orm['model_name'] # Return model in current state by name
|
||||||
|
|
||||||
|
> migrator.sql(sql) # Run custom SQL
|
||||||
|
> migrator.python(func, *args, **kwargs) # Run python code
|
||||||
|
> migrator.create_model(Model) # Create a model (could be used as decorator)
|
||||||
|
> migrator.remove_model(model, cascade=True) # Remove a model
|
||||||
|
> migrator.add_fields(model, **fields) # Add fields to a model
|
||||||
|
> migrator.change_fields(model, **fields) # Change fields
|
||||||
|
> migrator.remove_fields(model, *field_names, cascade=True)
|
||||||
|
> migrator.rename_field(model, old_field_name, new_field_name)
|
||||||
|
> migrator.rename_table(model, new_table_name)
|
||||||
|
> migrator.add_index(model, *col_names, unique=False)
|
||||||
|
> migrator.drop_index(model, *col_names)
|
||||||
|
> migrator.add_not_null(model, *field_names)
|
||||||
|
> migrator.drop_not_null(model, *field_names)
|
||||||
|
> migrator.add_default(model, field_name, default)
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import peewee as pw
|
||||||
|
from frigate.models import Event
|
||||||
|
|
||||||
|
SQL = pw.SQL
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(migrator, database, fake=False, **kwargs):
|
||||||
|
migrator.add_fields(
|
||||||
|
Event,
|
||||||
|
ratio=pw.FloatField(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def rollback(migrator, database, fake=False, **kwargs):
|
||||||
|
migrator.remove_fields(Event, ["ratio"])
|
||||||
Loading…
Reference in New Issue
Block a user