From cf40f9ecc5afb4fec2bc9b815ad3250fbde42728 Mon Sep 17 00:00:00 2001 From: vahidrezanezhad Date: Fri, 28 Mar 2025 20:58:32 +0100 Subject: [PATCH] The rotate_image function produces the exact same rotation as Imutils. Therefore, there is no need to retain the remove-imutils-1 branch. --- requirements.txt | 1 - src/eynollah/utils/__init__.py | 1 - src/eynollah/utils/rotate.py | 20 +++++++++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/requirements.txt b/requirements.txt index ef3fe31..9b821c3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,5 @@ ocrd >= 2.23.3 numpy <1.24.0 scikit-learn >= 0.23.2 tensorflow < 2.13 -imutils >= 0.5.3 numba <= 0.58.1 loky diff --git a/src/eynollah/utils/__init__.py b/src/eynollah/utils/__init__.py index a67fc38..faa32b0 100644 --- a/src/eynollah/utils/__init__.py +++ b/src/eynollah/utils/__init__.py @@ -4,7 +4,6 @@ import matplotlib.pyplot as plt import numpy as np from shapely import geometry import cv2 -import imutils from scipy.signal import find_peaks from scipy.ndimage import gaussian_filter1d import time diff --git a/src/eynollah/utils/rotate.py b/src/eynollah/utils/rotate.py index 603c2d9..0f2c177 100644 --- a/src/eynollah/utils/rotate.py +++ b/src/eynollah/utils/rotate.py @@ -1,6 +1,4 @@ import math - -import imutils import cv2 def rotatedRectWithMaxArea(w, h, angle): @@ -35,7 +33,7 @@ def rotate_max_area_new(image, rotated, angle): return rotated[y1:y2, x1:x2] def rotation_image_new(img, thetha): - rotated = imutils.rotate(img, thetha) + rotated = rotate_image(img, thetha) return rotate_max_area_new(img, rotated, thetha) def rotate_image(img_patch, slope): @@ -62,17 +60,17 @@ def rotate_max_area(image, rotated, rotated_textline, rotated_layout, rotated_ta return rotated[y1:y2, x1:x2], rotated_textline[y1:y2, x1:x2], rotated_layout[y1:y2, x1:x2], rotated_table_prediction[y1:y2, x1:x2] def rotation_not_90_func(img, textline, text_regions_p_1, table_prediction, thetha): - rotated = imutils.rotate(img, thetha) - rotated_textline = imutils.rotate(textline, thetha) - rotated_layout = imutils.rotate(text_regions_p_1, thetha) - rotated_table_prediction = imutils.rotate(table_prediction, thetha) + rotated = rotate_image(img, thetha) + rotated_textline = rotate_image(textline, thetha) + rotated_layout = rotate_image(text_regions_p_1, thetha) + rotated_table_prediction = rotate_image(table_prediction, thetha) return rotate_max_area(img, rotated, rotated_textline, rotated_layout, rotated_table_prediction, thetha) def rotation_not_90_func_full_layout(img, textline, text_regions_p_1, text_regions_p_fully, thetha): - rotated = imutils.rotate(img, thetha) - rotated_textline = imutils.rotate(textline, thetha) - rotated_layout = imutils.rotate(text_regions_p_1, thetha) - rotated_layout_full = imutils.rotate(text_regions_p_fully, thetha) + rotated = rotate_image(img, thetha) + rotated_textline = rotate_image(textline, thetha) + rotated_layout = rotate_image(text_regions_p_1, thetha) + rotated_layout_full = rotate_image(text_regions_p_fully, thetha) return rotate_max_area_full_layout(img, rotated, rotated_textline, rotated_layout, rotated_layout_full, thetha) def rotate_max_area_full_layout(image, rotated, rotated_textline, rotated_layout, rotated_layout_full, angle):