From 7b099a33da8f52927bc8dcb61ea0f1f152a0a265 Mon Sep 17 00:00:00 2001 From: "charles.ochoa" Date: Mon, 29 Aug 2022 00:04:56 +0000 Subject: [PATCH] fix: pr fixes --- dgp/annotations/camera_transforms.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dgp/annotations/camera_transforms.py b/dgp/annotations/camera_transforms.py index 320855e0..31812077 100644 --- a/dgp/annotations/camera_transforms.py +++ b/dgp/annotations/camera_transforms.py @@ -46,7 +46,6 @@ def calc_affine_transform( Parameters ---------- - theta: float Rotation angle in degrees. scale: float @@ -64,7 +63,6 @@ def calc_affine_transform( Returns ------- - A: np.ndarray 3x3 matrix that expresses the requested transformations. """ @@ -94,7 +92,7 @@ def calc_affine_transform( def box_crop_affine_transform( - box_xyxy: Tuple[int, int, int, int], + box_ltrb: Tuple[int, int, int, int], target_shape: Tuple[int, int], ) -> np.ndarray: """Generates a matrix that crops a rectangular area from an image and resizes it to target shape. @@ -102,8 +100,8 @@ def box_crop_affine_transform( Parameters ---------- - box_xyxy: list or tuple - Box corners expressed as x1,y1,x2,y2. + box_ltrb: list or tuple + Box corners expressed as left, top, right, bottom (x1,y1,x2,y2). target_shape: tuple Desired image shape (h,w) after cropping and resizing. @@ -113,7 +111,7 @@ def box_crop_affine_transform( 3x3 matrix that expresses the requested transformation. """ # get box center - x1, y1, x2, y2 = box_xyxy + x1, y1, x2, y2 = box_ltrb cx, cy = (x1 + x2) / 2, (y1 + y2) / 2 w, h = x2 - x1, y2 - y1 @@ -284,6 +282,8 @@ def transform_image( mode = PIL.Image.BILINEAR elif mode == cv2.INTER_NEAREST: mode = PIL.Image.NEAREST + else: + raise ValueError(f'{mode} not supported') new_img = tx.transform((w, h), img, resample=mode) else: @@ -304,7 +304,6 @@ def transform_camera( Returns ------- - mtxR: np.array new camera intrinsics new_pose: Pose @@ -316,7 +315,8 @@ def transform_camera( # Transform the camera matrix h, w = self.shape[:2] - # Flipping leads to the wrong rotation below, so when there is a flip present, we unflip, do everything, and re flip + # Flipping leads to the wrong rotation below, so when there is a flip present, + # we unflip, do everything, and re flip flip_mat = np.eye(3) flip = False if self.A[0, 0] < 0: @@ -499,12 +499,12 @@ def transform_mask_2d( Parameters ---------- - mask: np.ndarray + mask: np.ndarray, optional A boolean mask of same shape as the image that denotes a valid pixel Returns ------- - new_mask: np.ndarray + new_mask: np.ndarray, optional The transformed mask or None if the input mask was None """