breezedeus / CnSTD

CnSTD: 基于 PyTorch/MXNet 的 中文/英文 场景文字检测(Scene Text Detection)、数学公式检测(Mathematical Formula Detection, MFD)、篇章分析(Layout Analysis)的Python3 包
https://www.breezedeus.com/article/cnocr
Apache License 2.0
654 stars 101 forks source link

🔥得到的box中,weight和height有时是颠倒的 #37

Closed yfq512 closed 2 years ago

yfq512 commented 2 years ago

lala lala2

我发现得到的box中,weight和height有时是颠倒的,我只是把输出的box画在图上,未做任何调整,出现颠倒的概率还不低,我测过许多图片,都会出现这种情况。是我用法不对么?(左图直接画框,右图是经过自己的判断画的框)

from cnstd import CnStd
import cv2

std = CnStd()
img_path = 'imgs/4.jpg'
img = cv2.imread(img_path)
box_infos = std.detect(img_path)

for box_info in box_infos['detected_texts']:
    box = box_info['box']
    center_x = box[0]
    center_y = box[1]
    w = box[2]  
    h = box[3]

    first_point = (int(center_x - w / 2), int(center_y - h / 2))
    last_point = (int(center_x + w / 2), int(center_y + h / 2))
    cv2.rectangle(img, first_point, last_point, (0, 255, 0), 2)
cv2.imwrite('test.jpg', img)
breezedeus commented 2 years ago

调整 detect() 中的参数试试,尤其是其中的 resized_shape