-
Search before asking
QuestionHello everyone, maybe someone can help me out. I’m facing the following challenge: In my scene, a truck drives into an area and moves toward an unloading zone (always exactly one truck). However, YOLO returns multiple detection boxes for the same truck — for example parts of the trailer, the cab, or parts of the cargo. In principle the detection works, but I’d like to merge these boxes into a single one since they all overlap anyway. In Supervision, I found the function My current approach looks like this: import supervision as sv
from supervision.detection.core import merge_inner_detections_objects_without_iou
preds = np.hstack((detections.xyxy, detections.confidence.reshape(-1, 1), detections.class_id.reshape(-1, 1) ))
merge_groups = sv.box_non_max_merge( predictions=preds, iou_threshold=0.2, overlap_metric=sv.OverlapMetric.IOU)
merged_detections = []
for group in merge_groups:
per_detection = [detections[i] for i in group]
merged_detections.append(merge_inner_detections_objects_without_iou(per_detection))
detections = (
sv.Detections.merge(merged_detections)
if merged_detections
else sv.Detections.empty()
)Is this the intended way to use the function, or are there better methods to merge all overlapping boxes into a single truck bounding box? AdditionalNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Okay, I should have searched the Doc more thoroughly. Everything is easier with: detections = detections.with_nmm(threshold=0.2, overlap_metric=sv.OverlapMetric.IOU)If anyone ever faces the same challenge. |
Beta Was this translation helpful? Give feedback.
-
|
Using Your initial approach involved manually calling the low-level utility This feature was highlighted in the v0.21.0 release—you can read more about it in the release notes here. |
Beta Was this translation helpful? Give feedback.
Okay, I should have searched the Doc more thoroughly. Everything is easier with:
If anyone ever faces the same challenge.