open-mmlab / mmocr

OpenMMLab Text Detection, Recognition and Understanding Toolbox
https://mmocr.readthedocs.io/en/dev-1.x/
Apache License 2.0
4.27k stars 743 forks source link

how to get rectangle results when we do inference with fcenet model? #1082

Closed Gavinic closed 2 years ago

Gavinic commented 2 years ago

now the output is polygon as blew: image and the result in json file is:

image

my code is as blew: `from mmocr.utils.ocr import MMOCR ocr = MMOCR(det='FCE_IC15', recog=None, det_ckpt='epoch_10.pth')

推理

results = ocr.readtext('demo/demo_kie.jpeg', output='res/demo_kie_res.jpeg', export='res', print_result=True, merge=True, imshow=False) ` Thank you

Mountchicken commented 2 years ago

Hi @Gavinic FCENet is hardcoded to only produce polygon output. You can modify code here to produce quad output. https://github.com/open-mmlab/mmocr/blob/d068370b85e2eb84d83351a85dcfb531edc121a2/mmocr/models/textdet/postprocess/fce_postprocessor.py#L108-L109

      new_boundaries.append(points.reshape(-1).tolist() + [score]) 
return new_boundaries