From be1a0d32cac2ea79c0fe44c1455328d98087ebe0 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov <55749660+alexander1999-hub@users.noreply.github.com> Date: Thu, 5 Sep 2024 14:33:28 +0300 Subject: [PATCH] TLDR-784 added shift bbox method (#18) Co-authored-by: Alexander Golodkov --- CHANGELOG.md | 4 ++++ VERSION | 2 +- dedocutils/data_structures/bbox.py | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 777ba3f..cdd0f83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +v0.3.8 (2024-09-05) +------------------- +* Add `shift` method to `BBox` class + v0.3.7 (2024-07-22) ------------------- * Move `doctr` dependencies to a separate group diff --git a/VERSION b/VERSION index ce4f5af..4209dba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.7 \ No newline at end of file +0.3.8 \ No newline at end of file diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index 78dcf8b..bf14ac7 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -52,6 +52,10 @@ def y_bottom_right(self) -> int: def crop_image_by_box(image: np.ndarray, bbox: "BBox") -> np.ndarray: return image[bbox.y_top_left:bbox.y_bottom_right, bbox.x_top_left:bbox.x_bottom_right] + def shift(self, shift_x: int, shift_y: int) -> None: + self.x_top_left += shift_x + self.y_top_left += shift_y + def rotate_coordinates(self, angle_rotate: float, image_shape: Tuple[int]) -> None: xb, yb = self.x_top_left, self.y_top_left xe, ye = self.x_bottom_right, self.y_bottom_right