从图像面板中提取边界框



我使用以下代码检测所有文本并绘制所有边框:

from paddleocr import PaddleOCR,draw_ocr
ocr = PaddleOCR(lang='en') # need to run only once to download and load model into memory
img_path = 'PaddleOCR/doc/imgs_en/img_12.jpg'
result = ocr.ocr(img_path, cls=False)
for line in result:
print(line)
# draw result
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

现在我有一个图像与所有检测到的边界框。我想要分离所有的边界框,这样我就可以用pytesseract从它们中提取信息。我想这样做是因为paddleocr更适合检测,而Pytesserat更适合提取(德语)。那么我如何分离所有的边界框,从每个边界框中提取文本呢?谢谢你

每个检测框中四个点的排列顺序为左上、右上、右下、左下。

由于PP-OCR中的检测算法是逐行检测的,如果想从检测框坐标中得到每个单词的具体坐标,会比较困难。