Skip to content

Commit 2bf28c2

Browse files
committed
decoupled update_intrinsics_by_crop from update_intrinsics_by_center_crop
1 parent a54d0f9 commit 2bf28c2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/py_utils/utils_img.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,15 @@ def update_intrinsics_by_resized(K, orig_shape, resized_shape):
568568
return K_resized
569569

570570

571+
def update_intrinsics_by_crop(K, crop_top, crop_left):
572+
573+
K_cropped = K.copy()
574+
K_cropped[0, 2] -= crop_left
575+
K_cropped[1, 2] -= crop_top
576+
577+
return K_cropped
578+
579+
571580
def update_intrinsics_by_center_crop(K, orig_shape, resized_shape):
572581

573582
orig_h, orig_w = orig_shape[:2]
@@ -582,8 +591,4 @@ def update_intrinsics_by_center_crop(K, orig_shape, resized_shape):
582591
offset_y = orig_h // 2 - new_h // 2
583592
offset_x = orig_w // 2 - new_w // 2
584593

585-
K_cropped = K.copy()
586-
K_cropped[0, 2] -= offset_x
587-
K_cropped[1, 2] -= offset_y
588-
589-
return K_cropped
594+
return update_intrinsics_by_crop(K, offset_y, offset_x)

0 commit comments

Comments
 (0)