Closed yfq512 closed 2 years ago
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)
调整 detect() 中的参数试试,尤其是其中的 resized_shape
detect()
resized_shape
我发现得到的box中,weight和height有时是颠倒的,我只是把输出的box画在图上,未做任何调整,出现颠倒的概率还不低,我测过许多图片,都会出现这种情况。是我用法不对么?(左图直接画框,右图是经过自己的判断画的框)