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