使用cv2绘制bbox

使用cv2绘制bbox

img=np.zeros((300,400,3),np.uint8)
# bbox
# 逆时针
bbox = [[ 200.51428571,  160.03305785],
        [ 58.17723214,  160.03305785],
        [ 58.17723214,  210.6446281 ],
        [ 200.51428571,  210.6446281 ]]
bbox = np.array(bbox).astype(np.int)  # 转为整数
print('bbox:', bbox)

cv2.line(img, tuple(bbox[0]), tuple(bbox[1]), (255, 0, 0), 2)
cv2.line(img, tuple(bbox[1]), tuple(bbox[2]), (255, 0, 0), 2)
cv2.line(img, tuple(bbox[2]), tuple(bbox[3]), (255, 0, 0), 2)
cv2.line(img, tuple(bbox[3]), tuple(bbox[0]), (255, 0, 0), 2)
cv2.imshow('z',img)
cv2.waitKey()

使用cv2绘制bbox_第1张图片

cv2.polylines(img_path, [point], True, color, thickness)

你可能感兴趣的:(学习新知识)