def draw_joints_17(test_image, joints, save_image):
image = cv2.imread(test_image)
# bounding box
bbox = [min(joints[:, 0]), min(joints[:, 1]), max(joints[:, 0]), max(joints[:, 1])]
# draw bounding box in red rectangle
cv2.rectangle(image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), (0, 0, 255), 2)
# draw joints in green spots
for j in xrange(len(joints)):
cv2.circle(image, (joints[j, 0], joints[j, 1]), 5, (0, 255, 0), 2)
# draw head in yellow lines
head = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]
for item in head:
cv2.line(image, (joints[item[0], 0], joints[item[0], 1]), (joints[item[1], 0], joints[item[1], 1]), (0, 255, 255), 2)
# draw upper part in pink lines
upart = [[5, 6], [5, 7], [6, 8], [7, 9], [8, 10], [5, 11], [6, 12], [11, 12]]
for item in upart:
cv2.line(image, (joints[item[0], 0], joints[item[0], 1]), (joints[item[1], 0], joints[item[1], 1]), (255, 0, 255), 2)
# draw lower part in blue lines
lpart = [[11, 13], [12, 14], [13, 15], [14, 16]]
for item in lpart:
cv2.line(image, (joints[item[0], 0], joints[item[0], 1]), (joints[item[1], 0], joints[item[1], 1]), (255, 0, 0), 2)
cv2.imwrite(save_image, image)
评论列表
文章目录