新页面
This commit is contained in:
parent
512933f650
commit
540bc3813b
@ -56,7 +56,7 @@ namespace Wpf_AiSportsMicrospace.Common
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_webcamClient = WebcamClient.CreateRTSP("172.17.30.65", "admin", "yd708090", 554u);
|
_webcamClient = WebcamClient.CreateRTSP("172.17.30.64", "admin", "yd708090", 554u);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -163,7 +163,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
|||||||
private void OnTimePointReached(double timePoint)
|
private void OnTimePointReached(double timePoint)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"触发时间点: {timePoint}");
|
Console.WriteLine($"触发时间点: {timePoint}");
|
||||||
if (isMiss)
|
if (_isMiss)
|
||||||
{
|
{
|
||||||
head_m.Visibility = Visibility.Visible;
|
head_m.Visibility = Visibility.Visible;
|
||||||
miss.Visibility = Visibility.Visible;
|
miss.Visibility = Visibility.Visible;
|
||||||
|
|||||||
@ -14,6 +14,7 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
using Views.JumpRope;
|
||||||
using Wpf_AiSportsMicrospace;
|
using Wpf_AiSportsMicrospace;
|
||||||
using Wpf_AiSportsMicrospace.Common;
|
using Wpf_AiSportsMicrospace.Common;
|
||||||
using Wpf_AiSportsMicrospace.Enum;
|
using Wpf_AiSportsMicrospace.Enum;
|
||||||
@ -160,11 +161,16 @@ namespace Wpf_AiSportsMicrospace
|
|||||||
var newPage = new GroupJumpRope();
|
var newPage = new GroupJumpRope();
|
||||||
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
}
|
}
|
||||||
else
|
else if (coverFlow.SelectedIndex == 1)
|
||||||
{
|
{
|
||||||
var newPage = new MusicJumpRope();
|
var newPage = new MusicJumpRope();
|
||||||
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newPage = new TrainingRecords();
|
||||||
|
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
|
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
|||||||
@ -44,7 +44,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
|
|
||||||
// 容忍时间(节拍误差)
|
// 容忍时间(节拍误差)
|
||||||
public double _beatTolerance = 0.24; // ±150ms
|
public double _beatTolerance = 0.24; // ±150ms
|
||||||
private int _totalDots = 0;
|
|
||||||
// 滚动显示的节拍点集合
|
// 滚动显示的节拍点集合
|
||||||
public ObservableCollection<BeatItem> BeatDisplayLeft { get; set; } = new();
|
public ObservableCollection<BeatItem> BeatDisplayLeft { get; set; } = new();
|
||||||
public ObservableCollection<BeatItem> BeatDisplayRight { get; set; } = new();
|
public ObservableCollection<BeatItem> BeatDisplayRight { get; set; } = new();
|
||||||
@ -452,7 +451,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
if (humans == null || humans.Count == 0)
|
if (humans == null || humans.Count == 0)
|
||||||
return (int)WavingAction.None;
|
return (int)WavingAction.None;
|
||||||
|
|
||||||
|
|
||||||
foreach (var human in humans)
|
foreach (var human in humans)
|
||||||
{
|
{
|
||||||
if (human?.Keypoints == null)
|
if (human?.Keypoints == null)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Views.JumpRope"
|
xmlns:local="clr-namespace:Views.JumpRope"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
Height="1080" Width="1920" Loaded="UserControl_Loaded">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -10,6 +10,11 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Wpf_AiSportsMicrospace;
|
||||||
|
using Wpf_AiSportsMicrospace.Common;
|
||||||
|
using Wpf_AiSportsMicrospace.Enum;
|
||||||
|
using Wpf_AiSportsMicrospace.Views;
|
||||||
|
using Yztob.AiSports.Inferences.Things;
|
||||||
|
|
||||||
namespace Views.JumpRope
|
namespace Views.JumpRope
|
||||||
{
|
{
|
||||||
@ -18,9 +23,83 @@ namespace Views.JumpRope
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class TrainingRecords : UserControl
|
public partial class TrainingRecords : UserControl
|
||||||
{
|
{
|
||||||
|
private Main _mainWin => Application.Current.MainWindow as Main;
|
||||||
public TrainingRecords()
|
public TrainingRecords()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
Loaded += UserControl_Loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Utils.PlayBackgroundMusic("homeprojectselected.mp3", true);
|
||||||
|
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnHumanFrameUpdated(object sender, List<Human> humans)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (humans == null || humans.Count == 0) return;
|
||||||
|
|
||||||
|
int leftWaving = DetectLeftHandRaise(humans);
|
||||||
|
if (leftWaving == 5)
|
||||||
|
{
|
||||||
|
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
||||||
|
_mainWin.WebcamClient.StopExtract();
|
||||||
|
|
||||||
|
// 举左手逻辑,例如结束动画或退出
|
||||||
|
var newPage = new Home();
|
||||||
|
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("OnFrameExtracted error: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int DetectLeftHandRaise(List<Human> humans)
|
||||||
|
{
|
||||||
|
if (humans == null || humans.Count == 0)
|
||||||
|
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