Merge branch 'dev' of http://8.153.108.90:3000/YD/Wpf_AiSportsMicrospace into dev
This commit is contained in:
commit
3f97db7cf1
@ -56,7 +56,7 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
{
|
||||
try
|
||||
{
|
||||
_webcamClient = WebcamClient.CreateRTSP("172.17.30.65", "admin", "yd708090", 554u);
|
||||
_webcamClient = WebcamClient.CreateRTSP("172.17.30.64", "admin", "yd708090", 554u);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@ -86,6 +86,9 @@ namespace Dto
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
RankList = rankList;
|
||||
|
||||
return rankList;
|
||||
}
|
||||
public List<RankItem> UpdateScoreRankList()
|
||||
|
||||
@ -163,7 +163,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||
private void OnTimePointReached(double timePoint)
|
||||
{
|
||||
Console.WriteLine($"触发时间点: {timePoint}");
|
||||
if (isMiss)
|
||||
if (_isMiss)
|
||||
{
|
||||
head_m.Visibility = Visibility.Visible;
|
||||
miss.Visibility = Visibility.Visible;
|
||||
|
||||
@ -14,6 +14,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using Views.JumpRope;
|
||||
using Wpf_AiSportsMicrospace;
|
||||
using Wpf_AiSportsMicrospace.Common;
|
||||
using Wpf_AiSportsMicrospace.Enum;
|
||||
@ -160,11 +161,16 @@ namespace Wpf_AiSportsMicrospace
|
||||
var newPage = new GroupJumpRope();
|
||||
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||
}
|
||||
else
|
||||
else if (coverFlow.SelectedIndex == 1)
|
||||
{
|
||||
var newPage = new MusicJumpRope();
|
||||
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newPage = new TrainingRecords();
|
||||
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
|
||||
@ -44,7 +44,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
||||
|
||||
// 容忍时间(节拍误差)
|
||||
public double _beatTolerance = 0.24; // ±150ms
|
||||
private int _totalDots = 0;
|
||||
// 滚动显示的节拍点集合
|
||||
public ObservableCollection<BeatItem> BeatDisplayLeft { 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)
|
||||
return (int)WavingAction.None;
|
||||
|
||||
|
||||
foreach (var human in humans)
|
||||
{
|
||||
if (human?.Keypoints == null)
|
||||
|
||||
12
Wpf_AiSportsMicrospace/Views/JumpRope/TrainingRecords.xaml
Normal file
12
Wpf_AiSportsMicrospace/Views/JumpRope/TrainingRecords.xaml
Normal file
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Views.JumpRope.TrainingRecords"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Views.JumpRope"
|
||||
mc:Ignorable="d"
|
||||
Height="1080" Width="1920" Loaded="UserControl_Loaded">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
105
Wpf_AiSportsMicrospace/Views/JumpRope/TrainingRecords.xaml.cs
Normal file
105
Wpf_AiSportsMicrospace/Views/JumpRope/TrainingRecords.xaml.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// TrainingRecords.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TrainingRecords : UserControl
|
||||
{
|
||||
private Main _mainWin => Application.Current.MainWindow as Main;
|
||||
public TrainingRecords()
|
||||
{
|
||||
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