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
Where box is like this
[[ 67. 27.]
[119. 27.]
[119. 45.]
[ 67. 45.]]
If you want to use the array at the beginning, convert tolist into np format,
for example:
tl1 = np.array([19,48])
tl1 = tl1.tolist()
where the box contains the coordinates of 4 points