MCPcopy Create free account
hub / github.com/ZhengdiYu/SignAvatars / vis_keypoints

Function vis_keypoints

common/utils/vis.py:45–60  ·  view source on GitHub ↗
(img, kps, alpha=1)

Source from the content-addressed store, hash-verified

43 return cv2.addWeighted(img, 1.0 - alpha, kp_mask, alpha, 0)
44
45def vis_keypoints(img, kps, alpha=1):
46 # Convert from plt 0-1 RGBA colors to 0-255 BGR colors for opencv.
47 cmap = plt.get_cmap('rainbow')
48 colors = [cmap(i) for i in np.linspace(0, 1, len(kps) + 2)]
49 colors = [(c[2] * 255, c[1] * 255, c[0] * 255) for c in colors]
50
51 # Perform the drawing on a copy of the image, to allow for blending.
52 kp_mask = np.copy(img)
53
54 # Draw the keypoints.
55 for i in range(len(kps)):
56 p = kps[i][0].astype(np.int32), kps[i][1].astype(np.int32)
57 cv2.circle(kp_mask, p, radius=3, color=colors[i], thickness=-1, lineType=cv2.LINE_AA)
58
59 # Blend the keypoints.
60 return cv2.addWeighted(img, 1.0 - alpha, kp_mask, alpha, 0)
61
62def vis_mesh(img, mesh_vertex, alpha=0.5):
63 # Convert from plt 0-1 RGBA colors to 0-255 BGR colors for opencv.

Callers

nothing calls this directly

Calls 1

copyMethod · 0.80

Tested by

no test coverage detected