Skip to content

Commit

Permalink
Set optimized filter as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Agustin Castro committed Aug 16, 2022
1 parent 7242df5 commit 4cfcb76
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions demos/motmetrics4norfair/motmetrics4norfair.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np

from norfair import Tracker, drawing, metrics, video
from norfair.filter import FilterPyKalmanFilterFactory

frame_skip_period = 1
detection_threshold = 0.01
Expand Down Expand Up @@ -124,6 +125,7 @@ def keypoints_distance(detected_pose, tracked_pose):
detection_threshold=detection_threshold,
pointwise_hit_counter_max=pointwise_hit_counter_max,
hit_counter_max=hit_counter_max,
filter_factory=FilterPyKalmanFilterFactory(),
)

# Initialize accumulator for this video
Expand Down
2 changes: 2 additions & 0 deletions demos/motmetrics4norfair/motmetrics4norfair_xyah.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
sys.path.append('../../norfair')
from tracker import Tracker
from norfair import drawing, metrics, video, Detection
from norfair.filter import FilterPyKalmanFilterFactory

frame_skip_period = 1
detection_threshold = 0.01
Expand Down Expand Up @@ -129,6 +130,7 @@ def iou_xyah(detected_pose, tracked_pose):
detection_threshold=detection_threshold,
pointwise_hit_counter_max=pointwise_hit_counter_max,
hit_counter_max=hit_counter_max,
filter_factory=FilterPyKalmanFilterFactory(),
)

# Initialize accumulator for this video
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The class in charge of performing the tracking of the detections produced by the
- `initialization_delay (optional)`: The argument `initialization_delay` determines by how large the object's hit counter must be in order to be considered as initialized, and get returned to the user as a real object. It must be smaller than `hit_counter_max` or otherwise the object would never be initialized. If set to 0, objects will get returned to the user as soon as they are detected for the first time, which can be problematic as this can result in objects appearing and immediately dissapearing. Defaults to `hit_counter_max / 2`.
- `pointwise_hit_counter_max (optional)`: Each tracked object keeps track of how often the points it's tracking have been getting matched. Points that are getting matched (`pointwise_hit_counter > 0`) are said to be live, and points which aren't (`pointwise_hit_counter = 0`) are said to not be live. This is used to determine things like which individual points in a tracked object get drawn by [`draw_tracked_objects`](#draw_tracked_objects) and which don't. This argument (`pointwise_hit_counter_max`) defines how large the inertia for each point of a tracker can grow. Defaults to `5`.
- `detection_threshold (optional)`: Sets the threshold at which the scores of the points in a detection being fed into the tracker must dip below to be ignored by the tracker. Defaults to `0`.
- `filter_factory (optional)`: This parameter can be used to change what filter the [`TrackedObject`](#trackedobject) instances created by the tracker will use. Defaults to [`FilterPyKalmanFilterFactory()`](#filterpykalmanfilterfactory).
- `filter_factory (optional)`: This parameter can be used to change what filter the [`TrackedObject`](#trackedobject) instances created by the tracker will use. Defaults to [`OptimizedKalmanFilterFactory()`](#optimizedkalmanfilterfactory).
- `past_detections_length`: How many past detections to save for each tracked object. Norfair tries to distribute these past detections uniformly through the object's lifetime so they're more representative. Very useful if you want to add metric learning to your model, as you can associate an embedding to each detection and access them in your distance function. Defaults to `4`.

### Tracker.update
Expand Down
4 changes: 2 additions & 2 deletions norfair/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from norfair.distances import get_distance_by_name

from .filter import FilterPyKalmanFilterFactory
from .filter import OptimizedKalmanFilterFactory
from .utils import validate_points


Expand All @@ -19,7 +19,7 @@ def __init__(
initialization_delay: Optional[int] = None,
pointwise_hit_counter_max: int = 4,
detection_threshold: float = 0,
filter_factory: "FilterPyKalmanFilterFactory" = FilterPyKalmanFilterFactory(),
filter_factory: "FilterPyKalmanFilterFactory" = OptimizedKalmanFilterFactory(),
past_detections_length: int = 4,
):
self.tracked_objects: Sequence["TrackedObject"] = []
Expand Down

0 comments on commit 4cfcb76

Please sign in to comment.