From 8b6aa81e00e2418da68f0b51ae606d42abccf601 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 11 Oct 2025 14:54:57 +0800 Subject: [PATCH] tijiao --- Wpf_AiSportsMicrospace/App.xaml | 2 +- Wpf_AiSportsMicrospace/Common/SportOperate.cs | 10 ++++++++++ Wpf_AiSportsMicrospace/Views/Home.xaml.cs | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Wpf_AiSportsMicrospace/App.xaml b/Wpf_AiSportsMicrospace/App.xaml index 7a315bd..e299b3f 100644 --- a/Wpf_AiSportsMicrospace/App.xaml +++ b/Wpf_AiSportsMicrospace/App.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.Views" - StartupUri="Views/JumpRope/GroupJumpRope.xaml"> + StartupUri="Views/Home.xaml"> diff --git a/Wpf_AiSportsMicrospace/Common/SportOperate.cs b/Wpf_AiSportsMicrospace/Common/SportOperate.cs index 65f2ff9..e308105 100644 --- a/Wpf_AiSportsMicrospace/Common/SportOperate.cs +++ b/Wpf_AiSportsMicrospace/Common/SportOperate.cs @@ -60,6 +60,16 @@ namespace Wpf_AiSportsMicrospace.Common public int VerifyWavingAction(Human human) { + + var nose = human.Keypoints.FirstOrDefault(k => k.Name == "nose"); + if (nose == null) + return 0; + + // 使用 Canvas 宽度归一化 + double xNorm = nose.X / 1920; + if (!(xNorm >= 0.44 && xNorm <= 0.57)) + return 0; + var leftWrist = human.Keypoints.FirstOrDefault(x => x.Name == "left_wrist"); var leftElbow = human.Keypoints.FirstOrDefault(x => x.Name == "left_elbow"); var rightWrist = human.Keypoints.FirstOrDefault(x => x.Name == "right_wrist"); diff --git a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs index 61a89c4..a13c783 100644 --- a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs @@ -136,7 +136,7 @@ namespace Wpf_AiSportsMicrospace } else { - Thread.Sleep(5); + Thread.Sleep(5); } } }, _cts.Token); @@ -164,7 +164,6 @@ namespace Wpf_AiSportsMicrospace if (human == null) return; - //检测挥手动作 var wavingaction = _sportOperate.VerifyWavingAction(human); @@ -174,6 +173,8 @@ namespace Wpf_AiSportsMicrospace switch (wavingaction) { + case 0: // 点位验证失败 + break; case (int)WavingAction.LeftWave: // 左手挥动 Dispatcher.BeginInvoke(() => coverFlow.SlideRight()); break;