Skip to content

Conversation

@SkalskiP
Copy link
Collaborator

Description

This pull request refactors how aspect ratios for bounding boxes are calculated and accessed in the codebase. The main change is the removal of the standalone box_aspect_ratio utility function, which is now replaced by a new box_aspect_ratio property on the Detections class.

import numpy as np
import supervision as sv

xyxy = np.array([
    [10, 10, 50, 50],
    [60, 10, 180, 50],
    [10, 60, 50, 180],
])

detections = sv.Detections(xyxy=xyxy)

detections.box_aspect_ratio
# array([1.0, 3.0, 0.33333333])

ar = detections.box_aspect_ratio
detections[(ar < 2.0) & (ar > 0.5)].xyxy
# array([[10., 10., 50., 50.]])

@SkalskiP SkalskiP merged commit 6119f20 into develop Nov 16, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants