Spaces:
Running
Running
poly2rectangle bbox
Browse files- IndicPhotoOCR/ocr.py +9 -3
IndicPhotoOCR/ocr.py
CHANGED
@@ -54,9 +54,15 @@ class OCR:
|
|
54 |
for box in detections:
|
55 |
# Convert list of points to a numpy array with int type
|
56 |
points = np.array(box, np.int32)
|
57 |
-
|
58 |
-
#
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
# Show the image if 'show' is True
|
62 |
if show:
|
|
|
54 |
for box in detections:
|
55 |
# Convert list of points to a numpy array with int type
|
56 |
points = np.array(box, np.int32)
|
57 |
+
|
58 |
+
# Compute the top-left and bottom-right corners of the bounding box
|
59 |
+
x_min = np.min(points[:, 0])
|
60 |
+
y_min = np.min(points[:, 1])
|
61 |
+
x_max = np.max(points[:, 0])
|
62 |
+
y_max = np.max(points[:, 1])
|
63 |
+
|
64 |
+
# Draw the rectangle
|
65 |
+
cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color=(0, 255, 0), thickness=3)
|
66 |
|
67 |
# Show the image if 'show' is True
|
68 |
if show:
|