More stationary cleanup (#20229)
Some checks failed
CI / AMD64 Extra Build (push) Has been cancelled
CI / ARM Extra Build (push) Has been cancelled
CI / Synaptics Build (push) Has been cancelled
CI / Assemble and push default build (push) Has been cancelled
CI / AMD64 Build (push) Has been cancelled
CI / ARM Build (push) Has been cancelled
CI / Jetson Jetpack 6 (push) Has been cancelled

* Always return false for active objects

* Cleanup
This commit is contained in:
Nicolas Mowen 2025-09-26 07:23:29 -06:00 committed by GitHub
parent b8b07ee6e1
commit e6cbc93703
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -330,6 +330,18 @@ class NorfairTracker(ObjectTracker):
stationary: bool,
yuv_frame: np.ndarray | None,
) -> bool:
def reset_position(xmin: int, ymin: int, xmax: int, ymax: int) -> None:
self.positions[id] = {
"xmins": [xmin],
"ymins": [ymin],
"xmaxs": [xmax],
"ymaxs": [ymax],
"xmin": xmin,
"ymin": ymin,
"xmax": xmax,
"ymax": ymax,
}
xmin, ymin, xmax, ymax = box
position = self.positions[id]
self.stationary_box_history[id].append(box)
@ -360,16 +372,10 @@ class NorfairTracker(ObjectTracker):
if not self.stationary_classifier.evaluate(
id, yuv_frame, cast(tuple[int, int, int, int], tuple(box))
):
self.positions[id] = {
"xmins": [xmin],
"ymins": [ymin],
"xmaxs": [xmax],
"ymaxs": [ymax],
"xmin": xmin,
"ymin": ymin,
"xmax": xmax,
"ymax": ymax,
}
reset_position(xmin, ymin, xmax, ymax)
return False
else:
reset_position(xmin, ymin, xmax, ymax)
return False
threshold = (
@ -391,21 +397,15 @@ class NorfairTracker(ObjectTracker):
# if the median iou drops below the threshold
# assume object is no longer stationary
if median_iou < threshold:
# Before flipping to active, check with classifier if we have YUV frame
# If we have a yuv_frame to check before flipping to active, check with classifier if we have YUV frame
if stationary and yuv_frame is not None:
if not self.stationary_classifier.evaluate(
id, yuv_frame, cast(tuple[int, int, int, int], tuple(box))
):
self.positions[id] = {
"xmins": [xmin],
"ymins": [ymin],
"xmaxs": [xmax],
"ymaxs": [ymax],
"xmin": xmin,
"ymin": ymin,
"xmax": xmax,
"ymax": ymax,
}
reset_position(xmin, ymin, xmax, ymax)
return False
else:
reset_position(xmin, ymin, xmax, ymax)
return False
# if there are more than 5 and less than 10 entries for the position, add the bounding box