|
68 | 68 | print(f"{RED}{item.get_text()}{RESET}") |
69 | 69 |
|
70 | 70 | 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) |
79 | 73 |
|
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) |
85 | 77 |
|
86 | 78 | cv2.imshow( |
87 | 79 | os.path.basename(image_path), cv_image) |
|
0 commit comments