From 55daaf9d7b1ec6ebfc71520676d80cb5589b03c8 Mon Sep 17 00:00:00 2001 From: aaprasad Date: Fri, 3 May 2024 10:41:32 -0700 Subject: [PATCH] simplify pose centroid computation --- biogtr/datasets/data_utils.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/biogtr/datasets/data_utils.py b/biogtr/datasets/data_utils.py index 2304a25e..27aabbb3 100644 --- a/biogtr/datasets/data_utils.py +++ b/biogtr/datasets/data_utils.py @@ -113,7 +113,7 @@ def pose_bbox(points: np.ndarray, bbox_size: Union[tuple[int], int]) -> torch.Te """Calculate bbox around instance pose. Args: - instance: a labeled instance in a frame, + points: an np array of shape nodes x 2, bbox_size: size of bbox either an int indicating square bbox or in (x,y) Returns: @@ -122,16 +122,8 @@ def pose_bbox(points: np.ndarray, bbox_size: Union[tuple[int], int]) -> torch.Te if isinstance(bbox_size, int): bbox_size = (bbox_size, bbox_size) # print(points) - minx = np.nanmin(points[:, 0], axis=-1) - miny = np.nanmin(points[:, -1], axis=-1) - minpoints = np.array([minx, miny]).T - - maxx = np.nanmax(points[:, 0], axis=-1) - maxy = np.nanmax(points[:, -1], axis=-1) - maxpoints = np.array([maxx, maxy]).T - - c = (minpoints + maxpoints) / 2 + c = np.nanmean(points, axis=0) bbox = torch.Tensor( [ c[-1] - bbox_size[-1] / 2,