【深度学习】Human3.6M索引和部位

c 复制代码
joint_name={
'Hips(髋部)': 0,
'RightUpLeg(右大腿)': 1,
'RightLeg(右小腿)': 2,
'RightFoot(右脚)': 3,
'LeftUpLeg(左大腿)': 4,
'LeftLeg(左小腿)': 5,
'LeftFoot(左脚)': 6,
'Spine(脊柱)': 7,
'Spine1(脊柱1)': 8,
'Neck(颈部)': 9,
'Neck1(颈部1)': 10,
'LeftArm(左臂)': 11,
'LeftForeArm(左前臂)': 12,
'LeftHand(左手)': 13,
'RightArm(右臂)': 14,
'RightForeArm(右前臂)': 15,
'RightHand(右手)': 16
}

coco to h36m:

c 复制代码
def h36m_coco_format(keypoints, scores):
    assert len(keypoints.shape) == 4 and len(scores.shape) == 3
 
    h36m_kpts = []
    h36m_scores = []
    valid_frames = []
 
    for i in range(keypoints.shape[0]):
        kpts = keypoints[i]
        score = scores[i]
 
        new_score = np.zeros_like(score, dtype=np.float32)
 
        if np.sum(kpts) != 0.:
            kpts, valid_frame = coco_h36m(kpts)
            h36m_kpts.append(kpts)
            valid_frames.append(valid_frame)
 
            new_score[:, h36m_coco_order] = score[:, coco_order]
            new_score[:, 0] = np.mean(score[:, [11, 12]], axis=1, dtype=np.float32)
            new_score[:, 8] = np.mean(score[:, [5, 6]], axis=1, dtype=np.float32)
            new_score[:, 7] = np.mean(new_score[:, [0, 8]], axis=1, dtype=np.float32)
            new_score[:, 10] = np.mean(score[:, [1, 2, 3, 4]], axis=1, dtype=np.float32)
 
            h36m_scores.append(new_score)
 
    h36m_kpts = np.asarray(h36m_kpts, dtype=np.float32)
    h36m_scores = np.asarray(h36m_scores, dtype=np.float32)
 
    return h36m_kpts, h36m_scores, valid_frames

可视化:

c 复制代码
import numpy as np
 
 
import cv2
import numpy as np
import json
 
 
kpt_color_map = {'h': {'id': 0, 'color': [255, 0, 0], 'radius': 3, 'thickness': -1}, 'tail': {'id': 1, 'color': [0, 255, 0], 'radius': 2, 'thickness': -1}}
 
# 点类别文字
kpt_labelstr = {'font_size': 1,  # 字体大小
    'font_thickness': 3,  # 字体粗细
    'offset_x': 20,  # X 方向,文字偏移距离,向右为正
    'offset_y': 10,  # Y 方向,文字偏移距离,向下为正
}
 
labelme_path = r'E:\data\new_path\635_5225_02-1\input\0000.json'
with open(labelme_path, 'r', encoding='utf-8') as f:
    labelme = json.load(f)
 
img_bgr=cv2.imread(r'E:\data\new_path\635_5225_02-1\input\0000.png')
 
for each_ann in labelme['shapes']:  # 遍历每一个标注
 
 
    kpt_label = each_ann['label']  # 该点的类别
 
    for point in each_ann['points']:
        kpt_xy = point
        kpt_x, kpt_y = int(kpt_xy[0]), int(kpt_xy[1])
 
        # 该点的可视化配置
        kpt_color = kpt_color_map[kpt_label]['color']  # 颜色
        kpt_radius = kpt_color_map[kpt_label]['radius']  # 半径
        kpt_thickness = kpt_color_map[kpt_label]['thickness']  # 线宽(-1代表填充)
 
        # 画圆:画该关键点
        img_bgr = cv2.circle(img_bgr, (kpt_x, kpt_y), kpt_radius, kpt_color, kpt_thickness)
 
        # 写该点类别文字:图片,文字字符串,文字左上角坐标,字体,字体大小,颜色,字体粗细
        img_bgr = cv2.putText(img_bgr, kpt_label, (kpt_x + kpt_labelstr['offset_x'], kpt_y + kpt_labelstr['offset_y']), cv2.FONT_HERSHEY_SIMPLEX, kpt_labelstr['font_size'], kpt_color, kpt_labelstr['font_thickness'])
 
cv2.imshow('img',img_bgr)
cv2.waitKey(0)
 

参考:https://github.com/gauraviiita/Visualization-of-Human3.6M-Dataset/

相关推荐
weixin_46244623几秒前
【Dify 实战】基于 Workflow + LLM 的智能语音合成(TTS)完整教程(支持情感 / 语速 / 自动语言)
人工智能·语音识别·coze·mcp
乾元几秒前
社交工程 2.0:生成式 AI 驱动的高拟真钓鱼与认知对抗
网络·人工智能·安全·机器学习·架构
数字会议深科技1 分钟前
开放会场 / 封闭空间双兼容:同传系统的场景化解决方案革新
人工智能·翻译·政务·同声传译·会议系统品牌·会议解决方案·超大型会议
Katecat996632 分钟前
棉花质量检测与分类:基于YOLOv26的智能识别系统_2
人工智能·yolo
FPGA小c鸡2 分钟前
FPGA做AI:从入门到实战 | 边缘智能时代的硬件加速秘密
人工智能·fpga开发
悟能不能悟4 分钟前
什么是因果大模型
大数据·人工智能
思尔芯S2C5 分钟前
思尔芯、MachineWare与Andes晶心科技联合推出RISC-V协同仿真方案,加速芯片开发
人工智能·科技·fpga开发·risc-v·prototyping
LaughingZhu7 分钟前
Product Hunt 每日热榜 | 2026-01-26
大数据·人工智能·经验分享·搜索引擎·产品运营
科技AI训练师19 分钟前
CAXA CAD兼容性实测,老图纸与多格式文件的适配方案
人工智能·智能家居·vr
cs.shunzhang25 分钟前
告别繁琐set命令:在Windows PowerShell中优雅地管理网络代理设置
人工智能