正面蹲起
This commit is contained in:
parent
cdade14b61
commit
a33fe16ac1
@ -146,6 +146,7 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
if (_raiseStartTime == null) _raiseStartTime = DateTime.Now;
|
||||
if (_wristStartTime == null) _wristStartTime = DateTime.Now;
|
||||
|
||||
|
||||
var wristDuration = DateTime.Now - _wristStartTime.Value;
|
||||
|
||||
if (!_firstHandTriggered && wristDuration.TotalSeconds >= 1)
|
||||
|
||||
34
Wpf_AiSportsMicrospace/Optimizes.cs
Normal file
34
Wpf_AiSportsMicrospace/Optimizes.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Newtonsoft.Json;
|
||||
using Yztob.AiSports.Postures.Sports;
|
||||
using Yztob.AiSports.Postures.Things;
|
||||
|
||||
namespace Wpf_AiSportsMicrospace
|
||||
{
|
||||
public class Optimizes
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行运动微调
|
||||
/// </summary>
|
||||
/// <param name="sport">要微调的运动</param>
|
||||
public static void Optimizeing(SportBase sport)
|
||||
{
|
||||
if (sport == null)
|
||||
throw new ArgumentNullException(nameof(sport));
|
||||
|
||||
//获取运动的检测规则,如果使用的是规则检测时提供
|
||||
Console.WriteLine(JsonConvert.SerializeObject(sport.Rules));
|
||||
//获取运动的检测动作样本姿态,如果使用的是相似度时提供
|
||||
Console.WriteLine(JsonConvert.SerializeObject(sport.Samples));
|
||||
|
||||
switch (sport.Key)
|
||||
{
|
||||
case "squat":
|
||||
var loggicRule = sport.Rules["squat"] as CalcLogicAndRule;
|
||||
//删除手部姿态检查规则
|
||||
loggicRule.Rules.RemoveAt(2);
|
||||
loggicRule.Rules.RemoveAt(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
116
Wpf_AiSportsMicrospace/SportExpand/FrontSquat.cs
Normal file
116
Wpf_AiSportsMicrospace/SportExpand/FrontSquat.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Yztob.AiSports.Postures.Sports;
|
||||
using Yztob.AiSports.Postures.Things;
|
||||
|
||||
namespace SportExpand
|
||||
{
|
||||
/// <summary>
|
||||
/// 正面深蹲
|
||||
/// </summary>
|
||||
public class FrontSquat : SportSquat
|
||||
{
|
||||
public FrontSquat()
|
||||
{
|
||||
var loggicRule = this.Rules["squat"] as CalcLogicAndRule;
|
||||
//删除手部姿态检查规则
|
||||
//loggicRule.Rules.RemoveAt(2);
|
||||
//loggicRule.Rules.RemoveAt(1);
|
||||
|
||||
loggicRule.Rules.Clear();
|
||||
|
||||
// 新增下肢宽松规则
|
||||
// 1️⃣ 基础规则
|
||||
var baseRule = new CalcLogicAndRule()
|
||||
{
|
||||
Name = "基础检测(正面·宽松)",
|
||||
Rules = new List<CalcBaseRule>()
|
||||
{
|
||||
new CalcWholeRule()
|
||||
{
|
||||
Name = "全身入镜",
|
||||
Relaxed = true
|
||||
},
|
||||
new CalcStandRule()
|
||||
{
|
||||
Name = "站姿检测",
|
||||
Offset = 30
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 2️⃣ 腿部检测规则
|
||||
var legRule = new CalcLogicAndRule()
|
||||
{
|
||||
Name = "腿部检测(正面·宽松)",
|
||||
Rules = new List<CalcBaseRule>()
|
||||
{
|
||||
// ① 双腿横向张开(左右踝水平距离)
|
||||
new CalcHorizontalRule()
|
||||
{
|
||||
Name = "双腿张开",
|
||||
LeftKey = "left_ankle",
|
||||
RightKey = "right_ankle",
|
||||
Offset = 30 // 宽松偏差度数
|
||||
},
|
||||
|
||||
//// ② 膝盖不过内(左右一侧即可,可按需启用)
|
||||
//new CalcLogicOrRule()
|
||||
//{
|
||||
// Name = "膝盖不过内",
|
||||
// Rules = new List<CalcBaseRule>()
|
||||
// {
|
||||
// new CalcPositionRule()
|
||||
// {
|
||||
// Name = "左膝可接受",
|
||||
// ReferenceKey = "left_ankle",
|
||||
// PositionKey = "left_knee",
|
||||
// Position = "right",
|
||||
// Scope = 0.1f
|
||||
// },
|
||||
// new CalcPositionRule()
|
||||
// {
|
||||
// Name = "右膝可接受",
|
||||
// ReferenceKey = "right_ankle",
|
||||
// PositionKey = "right_knee",
|
||||
// Position = "left",
|
||||
// Scope = 0.1f
|
||||
// }
|
||||
// }
|
||||
//},
|
||||
|
||||
// ③ 下蹲动作(左右一侧即可,轻微下蹲)
|
||||
new CalcLogicOrRule()
|
||||
{
|
||||
Name = "下蹲动作",
|
||||
Rules = new List<CalcBaseRule>()
|
||||
{
|
||||
new CalcAngleRule()
|
||||
{
|
||||
Name = "左腿稍微下蹲",
|
||||
AngleKey = "left_knee",
|
||||
SecondKey = "left_hip",
|
||||
ThirdKey = "left_ankle",
|
||||
Angle = 120f, // 轻微下蹲角度
|
||||
Offset = 20f // 允许偏差
|
||||
},
|
||||
new CalcAngleRule()
|
||||
{
|
||||
Name = "右腿稍微下蹲",
|
||||
AngleKey = "right_knee",
|
||||
SecondKey = "right_hip",
|
||||
ThirdKey = "right_ankle",
|
||||
Angle = 120f,
|
||||
Offset = 20f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
loggicRule.Rules.Add(baseRule);
|
||||
loggicRule.Rules.Add(legRule);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using Dto;
|
||||
using Enum;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SportExpand;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
@ -468,8 +469,11 @@ namespace Views.SquatFu
|
||||
|
||||
// 绘制发光圆
|
||||
var userItem = AddUserItem(x, y, i);
|
||||
|
||||
// 绑定运动对象
|
||||
var sport = SportBase.Create("squat");
|
||||
var sport = new FrontSquat();
|
||||
|
||||
//Optimizes.Optimizeing(sport);
|
||||
|
||||
//var sport = SportBase.Create("rope-skipping");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user