def draw_text_det_res(dt_boxes, img_path):
"""
Visualize the results of detection
:param dt_boxes: The boxes predicted by detection model
:param img_path: Image path
:return: Visualized image
"""
src_im = cv2.imread(img_path)
for box in dt_boxes:
box = np.array(box).astype(np.int32).reshape(-1, 2)#转换成(-1, 2)的类型
cv2.polylines(src_im, [box], True, color=(255, 255, 0), thickness=2)
return src_im
其中box为这样的
[[ 67. 27.]
[119. 27.]
[119. 45.]
[ 67. 45.]]
要如果开始时数组的话要先用,tolist转换成np格式,
例如:
tl1 = np.array([19,48])
tl1 = tl1.tolist()
这里的box内含的是4个点的坐标