MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / draw_M

Function draw_M

tools/preprocess/human_visualization.py:255–408  ·  view source on GitHub ↗

Draw keypoints and connections representing hand pose on a given canvas. Args: canvas (np.ndarray): A 3D numpy array representing the canvas (image) on which to draw the hand pose. keypoints (List[Keypoint]| None): A list of Keypoint objects representing the hand keypoints

(img, kp2ds, threshold=0.6, data_to_json=None, idx=-1, kp2ds_lhand=None, kp2ds_rhand=None, draw_hand=False, stick_width_norm=200, draw_head=True)

Source from the content-addressed store, hash-verified

253
254
255def draw_M(img, kp2ds, threshold=0.6, data_to_json=None, idx=-1, kp2ds_lhand=None, kp2ds_rhand=None, draw_hand=False, stick_width_norm=200, draw_head=True):
256 """
257 Draw keypoints and connections representing hand pose on a given canvas.
258
259 Args:
260 canvas (np.ndarray): A 3D numpy array representing the canvas (image) on which to draw the hand pose.
261 keypoints (List[Keypoint]| None): A list of Keypoint objects representing the hand keypoints to be drawn
262 or None if no keypoints are present.
263
264 Returns:
265 np.ndarray: A 3D numpy array representing the modified canvas with the drawn hand pose.
266
267 Note:
268 The function expects the x and y coordinates of the keypoints to be normalized between 0 and 1.
269 """
270
271 new_kep_list = [
272 "Nose",
273 "Neck",
274 "RShoulder",
275 "RElbow",
276 "RWrist", # No.4
277 "LShoulder",
278 "LElbow",
279 "LWrist", # No.7
280 "RHip",
281 "RKnee",
282 "RAnkle", # No.10
283 "LHip",
284 "LKnee",
285 "LAnkle", # No.13
286 "REye",
287 "LEye",
288 "REar",
289 "LEar",
290 "LToe",
291 "RToe",
292 ]
293 # kp2ds_body = (kp2ds.copy()[[0, 6, 6, 8, 10, 5, 7, 9, 12, 14, 16, 11, 13, 15, 2, 1, 4, 3, 17, 20]] + \
294 # kp2ds.copy()[[0, 5, 6, 8, 10, 5, 7, 9, 12, 14, 16, 11, 13, 15, 2, 1, 4, 3, 18, 21]]) / 2
295 kp2ds = kp2ds.copy()
296 # import ipdb; ipdb.set_trace()
297 kp2ds[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 18, 19], 2] = 0
298 if not draw_head:
299 kp2ds[[0, 14, 15, 16, 17], 2] = 0
300 kp2ds_body = kp2ds
301 # kp2ds_body = kp2ds_body[:18]
302
303 # kp2ds_lhand = kp2ds.copy()[91:112]
304 # kp2ds_rhand = kp2ds.copy()[112:133]
305
306 limbSeq = [
307 # [2, 3],
308 # [2, 6], # shoulders
309 # [3, 4],
310 # [4, 5], # left arm
311 # [6, 7],
312 # [7, 8], # right arm

Callers 1

draw_aaface_by_metaFunction · 0.85

Calls 3

draw_handposeFunction · 0.85
copyMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected