RapidAI / RapidOCR

📄 Awesome OCR multiple programing languages toolkits based on ONNXRuntime, OpenVINO and PaddlePaddle.
https://rapidai.github.io/RapidOCRDocs
Apache License 2.0
3.13k stars 370 forks source link

det有时返回的box存在负数 #177

Closed SWHL closed 5 months ago

SWHL commented 6 months ago

Discussed in https://github.com/RapidAI/RapidOCR/discussions/169

det 有时返回的box竟然有负数,这种应该直接在后台设为0吧? [[412.0, -2.0], [514.0, -1.0], [513.0, 35.0], [411.0, 34.0]]

HiDolen commented 6 months ago

有原图吗

SWHL commented 6 months ago

我这里也没有原图,是Discussion #169 小伙伴提到的

HiDolen commented 6 months ago

按理说不该出问题呀。TextDecoder 里的后处理会用到 clip_det_res() 保证数值在合理范围内。

def clip_det_res(self, points, img_height, img_width):
        for pno in range(points.shape[0]):
            points[pno, 0] = int(min(max(points[pno, 0], 0), img_width - 1))
            points[pno, 1] = int(min(max(points[pno, 1], 0), img_height - 1))
        return points
SWHL commented 6 months ago

猜测可能是这里导致的: https://github.com/RapidAI/RapidOCR/blob/a8abd72dd64be8bc04ed2c3d3861ea6303f11982/python/rapidocr_onnxruntime/main.py#L98-L100

benjaminwan commented 6 months ago

存在负数的box代表此box在整张图的边缘,且识别结果可能不那么准确(比如截图边缘区域的一部分被截断了),个人认为应该保留负数这个特征。