Explorar o código

fix ocr visulize (#4073)

Zhang Zelun hai 5 meses
pai
achega
cd81dffe94
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      paddlex/inference/pipelines/ocr/result.py

+ 4 - 3
paddlex/inference/pipelines/ocr/result.py

@@ -91,13 +91,14 @@ class OCRResult(BaseCVResult):
                 box = np.array(box)
                 if len(box) > 4:
                     pts = [(x, y) for x, y in box.tolist()]
-                    draw_left.polygon(pts, outline=color, width=8)
+                    draw_left.polygon(pts, outline=color, width=8, fill=color)
                     box = self.get_minarea_rect(box)
                     height = int(0.5 * (max(box[:, 1]) - min(box[:, 1])))
                     box[:2, 1] = np.mean(box[:, 1])
                     box[2:, 1] = np.mean(box[:, 1]) + min(20, height)
-                box_pts = [(int(x), int(y)) for x, y in box.tolist()]
-                draw_left.polygon(box_pts, fill=color)
+                else:
+                    box_pts = [(int(x), int(y)) for x, y in box.tolist()]
+                    draw_left.polygon(box_pts, fill=color)
 
                 img_right_text = draw_box_txt_fine(
                     (w, h), box, txt, SIMFANG_FONT_FILE_PATH