首页 > 其他分享 >利用“姿态相似度比较”功能,对运动(动作)识别检测“秒”适配

利用“姿态相似度比较”功能,对运动(动作)识别检测“秒”适配

时间:2023-03-22 18:34:38浏览次数:57  
标签:right name 适配 score 相似 识别 姿态 left

本周迎来了「AI运动识别小程序插件」一个具有里程碑意义的功能更新:“姿态相似度比较”功能。利用此特性可以极大的提高您适配运动(动作)识别检测的速度,下面就将带您体验一下此特性的魅力。

一、确保将插件版本升级至v1.0.7

//app.json
``` javascript
{
	"plugins": {
        "aiSport": {
            "version": "1.0.7",
            "provider": "wx6130e578c4a26a1a"
        }
    }
}

二、姿态相似度比较API介绍

「姿态相似度比较」功能,是对给定的两组“人体关键点”进行分区及综合比较,并给出评分,省去了您在适配运动(动作)识别检测时,配置检测规则的繁琐。功能有三个主要对象放置在插件的calc命名空间,分别是:calc.PoseComparercalc.PoseComparerResultcalc.PoseComparerPartItem,详情的请参考api-docs

三、取姿态样本

进行姿态比较前您需要取一个标准姿态的关键点样本,您可以通过我们为您提供的「运动构建调试工具」来录制样本,
image

四、执行样本比较


//样本姿态人体关键点
const sample = 
 [{y:95.41808288282594,x:214.42673274576924,score:0.51611328125,name:"nose"},
 {y:84.61684727250136,x:221.80983627909686,score:0.7265625,name:"left_eye"},
 {y:87.59059985661885,x:202.12153237356293,score:0.59130859375,name:"right_eye"},
 {y:92.85449529945058,x:234.93538334278358,score:0.814453125,name:"left_ear"},
 {y:99.07546188234281,x:188.58581196413604,score:0.6806640625,name:"right_ear"},
 {y:149.86859452983884,x:271.3040866650822,score:0.7246093153953552,name:"left_shoulder"},
 {y:162.78905492065545,x:158.09624324078422,score:0.82666015625,name:"right_shoulder"},
 {y:236.41516213602512,x:280.8747980656871,score:0.728515625,name:"left_elbow"},
 {y:246.8062369181066,x:156.3188420992395,score:0.55859375,name:"right_elbow"},
 {y:305.46100866896046,x:286.61722490605007,score:0.6591796875,name:"left_wrist"},
 {y:313.80120003234475,x:152.9006975047454,score:0.70849609375,name:"right_wrist"},
 {y:304.5039375289,x:251.342317172392,score:0.87646484375,name:"left_hip"},
 {y:303.68360752741575,x:189.6796075527766,score:0.8740234375,name:"right_hip"},
 {y:431.38422581120494,x:237.66987231438497,score:0.70703125,name:"left_knee"},
 {y:430.01698132540423,x:189.6796075527766,score:0.8017578125,name:"right_knee"},
 {y:529.8258287888553,x:229.19295650242066,score:0.6884765625,name:"left_ankle"},
 {y:534.747908937738,x:201.71134233782658,score:0.578125,name:"right_ankle"}];

//当前帧动作,抽帧并且识别后,取人体识别结果中的keypoints
const frame = 
 [{y:154.06250001297832,x:258.7499999883252,score:0.728515625,name:"nose"},
 {y:143.12500001305142,x:254.37499998835446,score:0.56298828125,name:"left_eye"},
 {y:143.75001908653357,x:255.937499988344,score:0.69482421875,name:"right_eye"},
 {y:143.984394086532,x:229.99999998851743,score:0.43115234375,name:"left_ear"}
 ,{y:146.17187501303107,x:236.09374998847667,score:0.4919433891773224,name:"right_ear"},
 {y:201.4062690861481,x:205.9375190621646,score:0.51416015625,name:"left_shoulder"},
 {y:202.03125001265758,x:227.96874998853102,score:0.66259765625,name:"right_shoulder"},
 {y:281.25001908561427,x:234.6874999884861,score:0.26416015625,name:"left_elbow"},
 {y:270.6250190856853,x:254.06249998835656,score:0.278076171875,name:"right_elbow"},
 {y:246.09376908584932,x:289.06249998812257,score:0.1997070610523224,name:"left_wrist"},
 {y:238.43750001241418,x:300.62499998804526,score:0.50927734375,name:"right_wrist"},
 {y:321.5624618648858,x:218.59376906208004,score:0.58154296875,name:"left_hip"},
 {y:323.43750001184594,x:224.06249998855716,score:0.5615234375,name:"right_hip"},
 {y:453.43750001097675,x:217.34376906208837,score:0.6103515625,name:"left_knee"},
 {y:455.6250000109622,x:214.06249998862396,score:0.51416015625,name:"right_knee"},
 {y:572.5000000101808,x:215.31249998861563,score:0.403564453125,name:"left_ankle"},
 {y:593.1250000100429,x:216.0937499886104,score:0.52294921875,name:"right_ankle"}];

//新建比较器,执行比较
 const poseComparer = new AiSports.calc.PoseComparer();
 const result = poseComparer.compare(sample, frame);
 console.log(result);

//输出结果
//{items:
//         [{key:"head",score:0.4327263684686711,summary:"头部偏转相似度"},
//          {key:"trunk",score:0.8407704975917485,summary:"躯干形态相似度"},
//          {key:"left_hand",score:0.2155245751055277,summary:"左手相似度"},
//          {key:"right_hand",score:0.21361728579451628,summary:"左手相似度"},
//          {key:"left_foot",score:0.5147016736506456,summary:"左脚相似度"},
//          {key:"right_foot",score:0.5190758118853293,summary:"右脚相似度"}],
// score:0.5110266728697409  //整体相似度评分
//}

五、相似度结果应用

取得相似结果后,您可以根据运动(动作)的需求,直接进行总体评分或指定分区的评分判断(建议相似度在≥0.80时视为通过)。若有更精细的需求,也可以再配置一些加强规则进行再检测,详情请参考集成文档的body-calc相关章节。

注:目前相似度的比较,在前、后视角时置信度相对更高,正侧视图稍差些,后期我们将针对侧视图进行优化,敬请期待。

image

AI运动识别小程序插件介绍:

本插件可以为您的小程序提供人体检测、运动识别的AI能力,插件目前支持跳绳、开合跳、俯卧撑、仰卧起坐、深蹲(深蹲起)、平板支撑、马步蹲等运动的识别检测计时、计数分析,更多的运动类型正在丰富中;插件运动识别引擎提供了基于规则配置的运动识别能力,您可以通过配置一些简单的规则,增加一项新的运动(动作)识别能力,若是复杂的运动种类,也可以通过代码扩展的方式进行。

标签:right,name,适配,score,相似,识别,姿态,left
From: https://www.cnblogs.com/alphaair/p/17245022.html

相关文章