Utils#
A small grab-bag of helpers that don't fit anywhere else. Only two are part of the public API:
get_cutout— crops the axis-aligned bounding rectangle around a set of points out of an image. Handy for feeding a patch into a ReID / appearance model to build your own distance function.print_objects_as_table— pretty-prints the currentTrackedObjects as a Rich table (id, age, hit counter, last distance, init id). Useful for quickly debugging why the tracker is — or isn't — matching things.
Example#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
API#
Miscellaneous helpers: point validation, terminal sizing, warnings.
get_cutout(points, image)
#
Return the axis-aligned bounding-box cutout of points in image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
Array of shape |
required |
image
|
ndarray
|
Image array with at least two spatial dimensions (height, width, ...). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The cropped region. Returns an empty slice (with a warning) when the bounding box is degenerate (zero width or height after clipping). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If points is empty or does not have shape |
Source code in norfair/utils.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
print_objects_as_table(tracked_objects)
#
Pretty-print a table summarizing tracked_objects for debugging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracked_objects
|
Sequence
|
Sequence of tracked objects. Each element is expected to have
|
required |
Source code in norfair/utils.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |