Skip to content

Commit 97a450c

Browse files
committed
Update
1 parent 2453e8d commit 97a450c

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

examples/official/semi_font_ocr/read_semi_ocr.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,12 @@
6868
print(f"{RED}{item.get_text()}{RESET}")
6969

7070
location = item.get_location()
71-
x1 = location.points[0].x
72-
y1 = location.points[0].y
73-
x2 = location.points[1].x
74-
y2 = location.points[1].y
75-
x3 = location.points[2].x
76-
y3 = location.points[2].y
77-
x4 = location.points[3].x
78-
y4 = location.points[3].y
71+
points = [(p.x, p.y) for p in location.points]
72+
cv2.drawContours(cv_image, [np.intp(points)], 0, (0, 255, 0), 2)
7973

80-
cv2.drawContours(
81-
cv_image, [np.intp([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
82-
83-
cv2.putText(cv_image, item.get_text(), (x1 + 10, y1 + 20),
84-
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1)
74+
cv2.putText(cv_image, item.get_text(), (points[0][0] + 10, points[0][1] + 20),
75+
76+
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1)
8577

8678
cv2.imshow(
8779
os.path.basename(image_path), cv_image)

0 commit comments

Comments
 (0)