I need the bounding box of detected texts. However, because the detected text may not be a complete sentence, I wish the bounding box could be loose. What can I do? Belows are my code.
`box_list = []
ocrResult_list = []
conf_list = []
with PyTessBaseAPI() as api:
api.SetImage(image)
boxes = api.GetComponentImages(RIL.TEXTLINE, True)
# print("boxes\n", boxes)
# print('Found {} textline image components.'.format(len(boxes)))
for i, (im, box, _, _) in enumerate(boxes):
# im is a PIL image object
# box is a dict with x, y, w and h keys
api.SetRectangle(box['x'], box['y'], box['w'], box['h'])
ocrResult = api.GetUTF8Text()
conf = api.MeanTextConf()
box_list.append(box)
ocrResult_list.append(ocrResult[0:-1])
conf_list.append(conf)
# print(u"Box[{0}]: x={x}, y={y}, w={w}, h={h}, "
# "confidence: {1}, text: {2}".format(i, conf, ocrResult, **box))`
I need the bounding box of detected texts. However, because the detected text may not be a complete sentence, I wish the bounding box could be loose. What can I do? Belows are my code. `box_list = [] ocrResult_list = [] conf_list = []