4444
This commit is contained in:
parent
d1932b62a9
commit
9bed3d200b
@ -155,11 +155,9 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
|
||||
var now = DateTime.Now;
|
||||
|
||||
//_raiseStartTime ??= now;
|
||||
_wristStartTime ??= now;
|
||||
|
||||
double wristElapsed = (now - _wristStartTime.Value).TotalSeconds;
|
||||
//double raiseElapsed = (now - _raiseStartTime.Value).TotalSeconds;
|
||||
|
||||
// 第一步:触发倒计时 / 举手开始
|
||||
if (!_firstHandTriggered && wristElapsed >= 0)
|
||||
@ -168,15 +166,6 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
return (int)WavingAction.FirstHand;
|
||||
}
|
||||
|
||||
//if (wristElapsed <= 3)
|
||||
//{
|
||||
// return (int)WavingAction.Raising;
|
||||
//}
|
||||
|
||||
//_wristStartTime = null;
|
||||
//_firstHandTriggered = false;
|
||||
//return (int)WavingAction.RaiseHand;
|
||||
|
||||
// 第二步:举手完成
|
||||
if (wristElapsed >= 3)
|
||||
{
|
||||
|
||||
@ -45,10 +45,6 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||
Images[i].IsSelected = i == _selectedIndex;
|
||||
|
||||
UpdateLayoutWithAnimation();
|
||||
|
||||
// 启动进度条动画
|
||||
//var current = Images[_selectedIndex];
|
||||
//StartProgress(current);
|
||||
}
|
||||
|
||||
}
|
||||
@ -58,16 +54,6 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
Loaded += (s, e) => UpdateLayoutWithAnimation(true);
|
||||
|
||||
//var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(5) };
|
||||
//timer.Tick += (s, e) =>
|
||||
//{
|
||||
// if (Images.Count == 0) return;
|
||||
// var current = Images[_selectedIndex];
|
||||
// if (current.Progress < 1)
|
||||
// current.Progress += 0.01; // 调整速度
|
||||
//};
|
||||
//timer.Start();
|
||||
}
|
||||
private EventHandler _renderHandler;
|
||||
|
||||
@ -275,32 +261,13 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||
public async void SlideLeft()
|
||||
{
|
||||
StopProgress();
|
||||
|
||||
await Dispatcher.InvokeAsync(async () =>
|
||||
{
|
||||
while (ItemsHost.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
|
||||
await Task.Delay(10);
|
||||
|
||||
// 强制刷新布局
|
||||
ItemsHost.UpdateLayout();
|
||||
|
||||
SelectedIndex++;
|
||||
}, DispatcherPriority.ContextIdle);
|
||||
}
|
||||
|
||||
public async void SlideRight()
|
||||
{
|
||||
StopProgress();
|
||||
|
||||
await Dispatcher.InvokeAsync(async () =>
|
||||
{
|
||||
while (ItemsHost.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
|
||||
await Task.Delay(10);
|
||||
|
||||
ItemsHost.UpdateLayout();
|
||||
|
||||
SelectedIndex--;
|
||||
}, DispatcherPriority.ContextIdle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,8 +97,7 @@ namespace Wpf_AiSportsMicrospace
|
||||
{
|
||||
if (!IsGestureActive) return; // 手势识别已停止,直接返回
|
||||
|
||||
//var human = humans.FirstOrDefault();
|
||||
//if (human == null) return;
|
||||
if (humans == null || humans.Count == 0) return;
|
||||
|
||||
// 检测挥手动作
|
||||
var wavingaction = _mainWin.SportOperate.VerifyRightWavingAction(humans);
|
||||
@ -106,23 +105,15 @@ namespace Wpf_AiSportsMicrospace
|
||||
switch (wavingaction)
|
||||
{
|
||||
case (int)WavingAction.LeftWave: // 左手挥动
|
||||
//Application.Current.Dispatcher.Invoke(() => coverFlow.SlideRight());
|
||||
|
||||
|
||||
coverFlow.SlideRight();
|
||||
Application.Current.Dispatcher.BeginInvoke(() => coverFlow.SlideRight());
|
||||
break;
|
||||
|
||||
case (int)WavingAction.RightWave: // 右手挥动
|
||||
//Application.Current.Dispatcher.Invoke(() => coverFlow.SlideLeft());
|
||||
coverFlow.SlideLeft();
|
||||
Application.Current.Dispatcher.BeginInvoke(() => coverFlow.SlideLeft());
|
||||
break;
|
||||
|
||||
case (int)WavingAction.FirstHand: // 举手开始
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
coverFlow.StartSelectedProgress();
|
||||
}, DispatcherPriority.Render);
|
||||
//RouterGoNew();
|
||||
Application.Current.Dispatcher.BeginInvoke(() => coverFlow.StartSelectedProgress());
|
||||
break;
|
||||
|
||||
case (int)WavingAction.Raising: // 举手中,实时更新进度
|
||||
@ -130,14 +121,12 @@ namespace Wpf_AiSportsMicrospace
|
||||
|
||||
case (int)WavingAction.RaiseHand: // 举手完成
|
||||
// 设置标记,停止后续手势识别
|
||||
//IsGestureActive = false;
|
||||
RouterGoNew();
|
||||
|
||||
//coverFlow.ProgressCompleted += CoverFlow_ProgressCompleted;
|
||||
IsGestureActive = false;
|
||||
coverFlow.ProgressCompleted += CoverFlow_ProgressCompleted;
|
||||
break;
|
||||
|
||||
default: // 没有动作 → 取消进度
|
||||
//Application.Current.Dispatcher.BeginInvoke(() => coverFlow.CancelSelectedProgress());
|
||||
Application.Current.Dispatcher.BeginInvoke(() => coverFlow.CancelSelectedProgress());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -147,8 +136,8 @@ namespace Wpf_AiSportsMicrospace
|
||||
// 停止抽帧线程/释放资源
|
||||
try
|
||||
{
|
||||
//_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
||||
//_mainWin.WebcamClient.StopExtract();
|
||||
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
||||
_mainWin.WebcamClient.StopExtract();
|
||||
RouterGoNew();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -100,6 +100,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
_groupJumpRopeContext.CirclePositions = pointlist;
|
||||
|
||||
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
||||
_mainWin.WebcamClient.StartExtract();
|
||||
|
||||
DrawCirclesWithText();
|
||||
|
||||
|
||||
@ -110,6 +110,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
||||
|
||||
// 监听播放完成事件
|
||||
_mediaPlayer.MediaEnded += MediaPlayer_MediaEnded;
|
||||
_mainWin.WebcamClient.StartExtract();
|
||||
|
||||
_mediaPlayer.Play();
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ namespace Views.SquatFu
|
||||
// 播放音乐
|
||||
PlayMusic("raisehand.mp3");
|
||||
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
||||
|
||||
_mainWin.WebcamClient.StartExtract();
|
||||
}
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user