From 928a8c8ad94104e329f169cfb79e965fe9492bb0 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Wed, 4 Sep 2024 16:44:33 +0300 Subject: [PATCH 1/8] added shift bbox method --- dedocutils/data_structures/bbox.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index 78dcf8b..32befaa 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -52,6 +52,20 @@ 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] + @staticmethod + def shift_bbox(bbox: "BBox", shift_x: int, shift_y: int) -> "BBox": + """ + Shift bounding box by vector (shift_x, shift_y) + + :param bbox: original BBox to be shifted + :param shift_x: x coordinate offset + :param shift_y: y coordinate offset + """ + return BBox(x_top_left=bbox.x_top_left + shift_x, + y_top_left=bbox.y_top_left + shift_y, + width=bbox.width, + height=bbox.height) + 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 From 9fc83b838a04f7d8838c7b481e609c7c8a3883e0 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 12:48:58 +0300 Subject: [PATCH 2/8] style fix --- dedocutils/data_structures/bbox.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index 32befaa..103fd99 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -61,10 +61,7 @@ def shift_bbox(bbox: "BBox", shift_x: int, shift_y: int) -> "BBox": :param shift_x: x coordinate offset :param shift_y: y coordinate offset """ - return BBox(x_top_left=bbox.x_top_left + shift_x, - y_top_left=bbox.y_top_left + shift_y, - width=bbox.width, - height=bbox.height) + return BBox(x_top_left=bbox.x_top_left + shift_x, y_top_left=bbox.y_top_left + shift_y, width=bbox.width, height=bbox.height) def rotate_coordinates(self, angle_rotate: float, image_shape: Tuple[int]) -> None: xb, yb = self.x_top_left, self.y_top_left From 653a048e20e5ade8d26849fe3e3650b3239d0c3f Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 13:44:53 +0300 Subject: [PATCH 3/8] PR fix --- CHANGELOG.md | 4 ++++ dedocutils/data_structures/bbox.py | 13 +++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 777ba3f..cff0403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +v0.3.8 (2024-09-5) +------------------- +* Add `shift_bbox` method to `BBox` class + v0.3.7 (2024-07-22) ------------------- * Move `doctr` dependencies to a separate group diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index 103fd99..c287037 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -52,16 +52,9 @@ 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] - @staticmethod - def shift_bbox(bbox: "BBox", shift_x: int, shift_y: int) -> "BBox": - """ - Shift bounding box by vector (shift_x, shift_y) - - :param bbox: original BBox to be shifted - :param shift_x: x coordinate offset - :param shift_y: y coordinate offset - """ - return BBox(x_top_left=bbox.x_top_left + shift_x, y_top_left=bbox.y_top_left + shift_y, width=bbox.width, height=bbox.height) + def shift_bbox(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 From 842b6fb7e8c647f8ba173e78f68301c8fbfa5c62 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 14:18:42 +0300 Subject: [PATCH 4/8] small date fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cff0403..e52ef6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ Changelog ========= -v0.3.8 (2024-09-5) +v0.3.8 (2024-09-05) ------------------- * Add `shift_bbox` method to `BBox` class From d824876823251604b19bc1357466a6bd3fd6561d Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 14:21:07 +0300 Subject: [PATCH 5/8] version fix --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ad62fc6e22dabc5a3d70114473d07c46d56bb68e Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 14:22:55 +0300 Subject: [PATCH 6/8] small fix --- dedocutils/data_structures/bbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index c287037..bf14ac7 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -52,7 +52,7 @@ 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_bbox(self, shift_x: int, shift_y: int) -> None: + def shift(self, shift_x: int, shift_y: int) -> None: self.x_top_left += shift_x self.y_top_left += shift_y From f20e0eb6ca808e72dbaef3898c94761be06afb49 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 14:27:21 +0300 Subject: [PATCH 7/8] small fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e52ef6d..64649cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ Changelog v0.3.8 (2024-09-05) ------------------- -* Add `shift_bbox` method to `BBox` class +* Add `shift?` method to `BBox` class v0.3.7 (2024-07-22) ------------------- From 8c3ae3da94e7971b7d8095bc9d90e736ff46f040 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov Date: Thu, 5 Sep 2024 14:27:51 +0300 Subject: [PATCH 8/8] small fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64649cd..cdd0f83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ Changelog v0.3.8 (2024-09-05) ------------------- -* Add `shift?` method to `BBox` class +* Add `shift` method to `BBox` class v0.3.7 (2024-07-22) -------------------