从CPM得出关节置信度

编程入门 行业动态 更新时间:2024-10-19 16:23:57

从CPM得出<a href=https://www.elefans.com/category/jswz/34/1698269.html style=关节置信度"/>

从CPM得出关节置信度

从cpm得到关节置信度的问题

为了从smplify项目中使用自己的数据集,所以采用cpm制作相应图片的数据集,但是fit_3d.py的输入是14x3的矩阵,包括了每个关节的置信度,而直接运行demo_cpm_body.py是不能直接得到关节点的置信度的,得到是一个14x2的矩阵,无法满足fit_3d的输入要求,为了制作自己的关节点我们需要对代码进行修改。

注:官方文档建议的是两种方式可以得到数据集,一种是cpm,另一种是deepcut cnn

大致看了下cpm的论文,以及相应的代码结构,发现过程中用到了热力图,热力图用来表示关节的准确情况,这样一来,我们就可以根据热力度来得到置信度,并将置信度的结果合并形成最终我们需要的结果,即包含关节置信度的14x3矩阵。
相关代码段如下:

    if kalman_filter_array is not None:for joint_num in range(FLAGS.joints):conf.append(np.max(last_heatmap[:, :, joint_num]))joint_coord = np.unravel_index(np.argmax(last_heatmap[:, :, joint_num]),(test_img.shape[0], test_img.shape[1]))# add a dimension for kalman filterjoint_coord = np.array(joint_coord).reshape((2, 1)).astype(np.float32)kalman_filter_array[joint_num].correct(joint_coord)kalman_pred = kalman_filter_array[joint_num].predict()joint_coord_set[joint_num, :] = np.array([kalman_pred[0], kalman_pred[1]]).reshape((2))color_code_num = (joint_num // 4)if joint_num in [0, 4, 8, 12, 16]:if PYTHON_VERSION == 3:joint_color = list(map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num]))else:joint_color = map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num])cv2.circle(test_img, center=(joint_coord[1], joint_coord[0]), radius=3, color=joint_color, thickness=-1)else:if PYTHON_VERSION == 3:joint_color = list(map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num]))else:joint_color = map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num])cv2.circle(test_img, center=(joint_coord[1], joint_coord[0]), radius=3, color=joint_color, thickness=-1)else:for joint_num in range(FLAGS.joints):conf.append(np.max(last_heatmap[:, :, joint_num]))joint_coord = np.unravel_index(np.argmax(last_heatmap[:, :, joint_num]),(test_img.shape[0], test_img.shape[1]))joint_coord_set[joint_num, :] = [joint_coord[0], joint_coord[1]]color_code_num = (joint_num // 4)if joint_num in [0, 4, 8, 12, 16]:if PYTHON_VERSION == 3:joint_color = list(map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num]))else:joint_color = map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num])cv2.circle(test_img, center=(joint_coord[1], joint_coord[0]), radius=3, color=joint_color, thickness=-1)else:if PYTHON_VERSION == 3:joint_color = list(map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num]))else:joint_color = map(lambda x: x + 35 * (joint_num % 4), joint_color_code[color_code_num])cv2.circle(test_img, center=(joint_coord[1], joint_coord[0]), radius=3, color=joint_color, thickness=-1)

上述代码中的

conf.append(np.max(last_heatmap[:, :, joint_num]))

就是在每个关节的热力图,找出 热力值的最大值 作为该关节点的 置信度。(因为热力值的范围为0-1)

上图为热力值的打印部分结果

更多推荐

从CPM得出关节置信度

本文发布于:2023-07-28 17:00:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1256780.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:关节   CPM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!