Skip to content

Commit

Permalink
Use new drawing functions in camera_modetion demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Agustín Castro committed Jan 30, 2024
1 parent 6311640 commit 18920ae
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions demos/camera_motion/src/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
Tracker,
Video,
draw_absolute_grid,
draw_tracked_boxes,
)

from norfair.camera_motion import (
HomographyTransformationGetter,
MotionEstimator,
TranslationTransformationGetter,
)
from norfair.drawing import draw_tracked_objects

from norfair.drawing import draw_points, draw_boxes


def yolo_detections_to_norfair_detections(yolo_detections, track_boxes):
Expand Down Expand Up @@ -66,7 +67,7 @@ def run():
parser.add_argument(
"--distance-threshold",
type=float,
default=0.8,
default=None,
help="Max distance to consider when matching detections and tracked objects",
)
parser.add_argument(
Expand Down Expand Up @@ -223,10 +224,22 @@ def run():
else partial(video.show, downsample_ratio=args.downsample_ratio)
)

distance_threshold = args.distance_threshold
if args.track_boxes:
drawing_function = draw_boxes
distance_function = "iou"
if args.distance_threshold is None:
distance_threshold = 0.5
else:
drawing_function = draw_points
distance_function = "euclidean"
if args.distance_threshold is None:
distance_threshold = video.input_height / 10

tracker = Tracker(
distance_function="euclidean",
distance_function=distance_function,
detection_threshold=args.confidence_threshold,
distance_threshold=args.distance_threshold,
distance_threshold=distance_threshold,
initialization_delay=args.initialization_delay,
hit_counter_max=args.hit_counter_max,
)
Expand Down Expand Up @@ -259,11 +272,11 @@ def run():
)

if args.draw_objects:
draw_tracked_objects(
drawing_function(
frame,
tracked_objects,
id_size=args.id_size,
id_thickness=None
text_size=args.id_size,
text_thickness=None
if args.id_size is None
else int(args.id_size * 2),
)
Expand Down

0 comments on commit 18920ae

Please sign in to comment.