Skip to content

Commit

Permalink
PR fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Golodkov committed Sep 5, 2024
1 parent 9fc83b8 commit 653a048
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 3 additions & 10 deletions dedocutils/data_structures/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 653a048

Please sign in to comment.