更新
This commit is contained in:
parent
6d248c8892
commit
3d97ce0dc7
@ -55,10 +55,12 @@ namespace Wpf_AiSportsMicrospace
|
|||||||
Unloaded += Home_Unloaded;
|
Unloaded += Home_Unloaded;
|
||||||
|
|
||||||
Utils.PlayBackgroundMusic("homeprojectselected.mp3", true);
|
Utils.PlayBackgroundMusic("homeprojectselected.mp3", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
||||||
|
_mainWin.WebcamClient.StartExtract();
|
||||||
}
|
}
|
||||||
private void Home_Unloaded(object sender, RoutedEventArgs e)
|
private void Home_Unloaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -200,6 +200,9 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
int leftWaving = DetectLeftHandRaise(humans);
|
int leftWaving = DetectLeftHandRaise(humans);
|
||||||
if (leftWaving == 5)
|
if (leftWaving == 5)
|
||||||
{
|
{
|
||||||
|
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
||||||
|
_mainWin.WebcamClient.StopExtract();
|
||||||
|
|
||||||
// 举左手逻辑,例如结束动画或退出
|
// 举左手逻辑,例如结束动画或退出
|
||||||
var newPage = new Home();
|
var newPage = new Home();
|
||||||
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
@ -272,11 +275,16 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
x.ImageState = "1";
|
x.ImageState = "1";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
||||||
|
_mainWin.WebcamClient.StopExtract();
|
||||||
|
|
||||||
RankingItemList = _groupJumpRopeContext.UpdateRankList();
|
RankingItemList = _groupJumpRopeContext.UpdateRankList();
|
||||||
ShowRankingBoard(RankingItemList);
|
ShowRankingBoard(RankingItemList);
|
||||||
Utils.StopBackgroundMusic();
|
Utils.StopBackgroundMusic();
|
||||||
|
|
||||||
_currentGameState = GameState.Finished;
|
_currentGameState = GameState.Finished;
|
||||||
|
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
||||||
|
_mainWin.WebcamClient.StartExtract();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime? _raiseStartTime;
|
private DateTime? _raiseStartTime;
|
||||||
@ -374,6 +382,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
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)
|
||||||
@ -389,7 +398,6 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
if (!(xNorm >= 0.44 && xNorm <= 0.57 && yNorm >= 0.81))
|
if (!(xNorm >= 0.44 && xNorm <= 0.57 && yNorm >= 0.81))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
// 获取左手关键点
|
// 获取左手关键点
|
||||||
var leftWrist = human.Keypoints.FirstOrDefault(k => k.Name == "left_wrist");
|
var leftWrist = human.Keypoints.FirstOrDefault(k => k.Name == "left_wrist");
|
||||||
var leftElbow = human.Keypoints.FirstOrDefault(k => k.Name == "left_elbow");
|
var leftElbow = human.Keypoints.FirstOrDefault(k => k.Name == "left_elbow");
|
||||||
@ -400,7 +408,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
const double raiseThreshold = 60; // 举手阈值
|
const double raiseThreshold = 60; // 举手阈值
|
||||||
|
|
||||||
// 判断左手是否举起
|
// 判断左手是否举起
|
||||||
double verticalRise = leftWrist.Y - leftElbow.Y;
|
double verticalRise = leftElbow.Y - leftWrist.Y;
|
||||||
if (verticalRise >= raiseThreshold)
|
if (verticalRise >= raiseThreshold)
|
||||||
{
|
{
|
||||||
return (int)WavingAction.RaiseHand; // 一旦检测到左手举起,立即返回
|
return (int)WavingAction.RaiseHand; // 一旦检测到左手举起,立即返回
|
||||||
@ -577,7 +585,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
Height = 71,
|
Height = 71,
|
||||||
HorizontalAlignment = HorizontalAlignment.Center,
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
VerticalAlignment = VerticalAlignment.Top,
|
VerticalAlignment = VerticalAlignment.Top,
|
||||||
Margin = new Thickness(0, 57 * item.Rank, 0, 0)
|
Margin = new Thickness(0, 69 * item.Rank, 0, 0)
|
||||||
};
|
};
|
||||||
var border = new Border
|
var border = new Border
|
||||||
{
|
{
|
||||||
|
|||||||
@ -110,10 +110,6 @@ namespace Wpf_AiSportsMicrospace.Views
|
|||||||
var humans = humanResult?.Humans?.ToList();
|
var humans = humanResult?.Humans?.ToList();
|
||||||
if (humans == null || humans.Count == 0)
|
if (humans == null || humans.Count == 0)
|
||||||
return;
|
return;
|
||||||
foreach (var human in humans)
|
|
||||||
{
|
|
||||||
_detectQueue.Enqueue(frame.Number, human, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 触发全局事件
|
// 触发全局事件
|
||||||
Application.Current.Dispatcher.BeginInvoke(() =>
|
Application.Current.Dispatcher.BeginInvoke(() =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user