MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / points_to_bbox

Function points_to_bbox

detrsmpl/models/utils/SMPLX.py:119–134  ·  view source on GitHub ↗

Get scaled bounding box from keypoints 2D.

(points, bbox_scale_factor: float = 1.0)

Source from the content-addressed store, hash-verified

117
118
119def points_to_bbox(points, bbox_scale_factor: float = 1.0):
120 """Get scaled bounding box from keypoints 2D."""
121 min_coords, _ = torch.min(points, dim=1)
122 xmin, ymin = min_coords[:, 0], min_coords[:, 1]
123 max_coords, _ = torch.max(points, dim=1)
124 xmax, ymax = max_coords[:, 0], max_coords[:, 1]
125
126 center = torch.stack([xmax + xmin, ymax + ymin], dim=-1) * 0.5
127
128 width = (xmax - xmin)
129 height = (ymax - ymin)
130
131 # Convert the bounding box to a square box
132 size = torch.max(width, height) * bbox_scale_factor
133
134 return center, size
135
136
137def get_crop_info(points,

Callers 1

get_crop_infoFunction · 0.85

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected