MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / vis_keypoints

Function vis_keypoints

HMR-Scorer/common/utils/vis.py:44–63  ·  view source on GitHub ↗
(img, kps, alpha=1, radius=3, color=None)

Source from the content-addressed store, hash-verified

42 return cv2.addWeighted(img, 1.0 - alpha, kp_mask, alpha, 0)
43
44def vis_keypoints(img, kps, alpha=1, radius=3, color=None):
45 # Convert from plt 0-1 RGBA colors to 0-255 BGR colors for opencv.
46 cmap = plt.get_cmap('rainbow')
47 if color is None:
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 if color is None:
58 cv2.circle(kp_mask, p, radius=radius, color=colors[i], thickness=-1, lineType=cv2.LINE_AA)
59 else:
60 cv2.circle(kp_mask, p, radius=radius, color=color, thickness=-1, lineType=cv2.LINE_AA)
61
62 # Blend the keypoints.
63 return cv2.addWeighted(img, 1.0 - alpha, kp_mask, alpha, 0)
64
65def vis_mesh(img, mesh_vertex, alpha=0.5):
66 # Convert from plt 0-1 RGBA colors to 0-255 BGR colors for opencv.

Callers 1

render_meshFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected