tiaozhuan
This commit is contained in:
parent
534071ebc1
commit
147631122b
@ -195,7 +195,7 @@ namespace Wpf_AiSportsMicrospace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newPage = new StandingLeap();
|
var newPage = new TrainingRecords();
|
||||||
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Dto;
|
using Dto;
|
||||||
|
using SportExpand;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -16,6 +17,7 @@ using Wpf_AiSportsMicrospace.Common;
|
|||||||
using Wpf_AiSportsMicrospace.Enum;
|
using Wpf_AiSportsMicrospace.Enum;
|
||||||
using Wpf_AiSportsMicrospace.Views;
|
using Wpf_AiSportsMicrospace.Views;
|
||||||
using Yztob.AiSports.Inferences.Things;
|
using Yztob.AiSports.Inferences.Things;
|
||||||
|
using Yztob.AiSports.Postures;
|
||||||
|
|
||||||
namespace Views.JumpRope
|
namespace Views.JumpRope
|
||||||
{
|
{
|
||||||
@ -48,19 +50,29 @@ namespace Views.JumpRope
|
|||||||
{
|
{
|
||||||
if (humans == null || humans.Count == 0) return;
|
if (humans == null || humans.Count == 0) return;
|
||||||
|
|
||||||
int leftWaving = DetectLeftHandRaise(humans);
|
var human = humans.FirstOrDefault(h =>
|
||||||
|
{
|
||||||
|
var rightAnkle = h.Keypoints.FirstOrDefault(k => k.Name == "right_ankle");
|
||||||
|
if (rightAnkle == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
double xNorm = rightAnkle.X / 1920.0;
|
||||||
|
double yNorm = rightAnkle.Y / 1080.0;
|
||||||
|
|
||||||
|
return xNorm >= 0.44 && xNorm <= 0.57 && yNorm >= 0.81;
|
||||||
|
});
|
||||||
|
if (human != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
int leftWaving = DetectLeftHandRaise(human);
|
||||||
if (leftWaving == 5)
|
if (leftWaving == 5)
|
||||||
{
|
{
|
||||||
//_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
|
||||||
if (newPage == null)
|
if (newPage == null)
|
||||||
{
|
{
|
||||||
newPage = new Home();
|
newPage = new Home();
|
||||||
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
}
|
}
|
||||||
// 举左手逻辑,例如结束动画或退出
|
}
|
||||||
|
|
||||||
//return;
|
|
||||||
//_mainWin.WebcamClient.StopExtract();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,45 +153,20 @@ namespace Views.JumpRope
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int DetectLeftHandRaise(List<Human> humans)
|
public int DetectLeftHandRaise(Human human)
|
||||||
{
|
{
|
||||||
if (humans == null || humans.Count == 0)
|
var calculator = PostureCalculate.CreateCalculator();
|
||||||
|
var rule = RaiseHand.RaiseLeftHand();
|
||||||
|
var pass = calculator.Calculating(human, rule);
|
||||||
|
|
||||||
|
if (pass)
|
||||||
|
{
|
||||||
|
// 一旦检测到左手举起,立即返回
|
||||||
|
return (int)WavingAction.RaiseHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 没有检测到举手
|
||||||
return (int)WavingAction.None;
|
return (int)WavingAction.None;
|
||||||
|
|
||||||
|
|
||||||
foreach (var human in humans)
|
|
||||||
{
|
|
||||||
if (human?.Keypoints == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// --- 筛选右脚踝坐标 ---
|
|
||||||
var rightAnkle = human.Keypoints.FirstOrDefault(k => k.Name == "right_ankle");
|
|
||||||
if (rightAnkle == null)
|
|
||||||
continue;
|
|
||||||
double xNorm = rightAnkle.X / 1920;
|
|
||||||
double yNorm = rightAnkle.Y / 1080;
|
|
||||||
// 仅检测中心区域内的人
|
|
||||||
if (!(xNorm >= 0.44 && xNorm <= 0.57 && yNorm >= 0.81))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 获取左手关键点
|
|
||||||
var leftWrist = human.Keypoints.FirstOrDefault(k => k.Name == "left_wrist");
|
|
||||||
var leftElbow = human.Keypoints.FirstOrDefault(k => k.Name == "left_elbow");
|
|
||||||
|
|
||||||
if (leftWrist == null || leftElbow == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const double raiseThreshold = 60; // 举手阈值
|
|
||||||
|
|
||||||
// 判断左手是否举起
|
|
||||||
double verticalRise = leftElbow.Y - leftWrist.Y;
|
|
||||||
if (verticalRise >= raiseThreshold)
|
|
||||||
{
|
|
||||||
return (int)WavingAction.RaiseHand; // 一旦检测到左手举起,立即返回
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int)WavingAction.None; // 没有检测到举手
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user