This commit is contained in:
tanglong 2026-03-11 13:16:02 +08:00
parent cbf1728489
commit d1932b62a9
3 changed files with 40 additions and 12 deletions

View File

@ -31,7 +31,7 @@ namespace Wpf_AiSportsMicrospace.Common
IPointTracker _rightTracker;
private int _leftWaveCount = 0;
private int _rightWaveCount = 0;
private const int WaveThreshold =1;
private const int WaveThreshold = 3;
WebcamClient _webcamClient;
private DateTime? _wristStartTime = null;
@ -43,8 +43,8 @@ namespace Wpf_AiSportsMicrospace.Common
_leftTracker = PostureCalculate.CreatePointTracker("left_wrist", 0);
_rightTracker = PostureCalculate.CreatePointTracker("right_wrist", 0);
_leftTracker.Amplitude = 0.3f;
_rightTracker.Amplitude = 0.3f;
//_leftTracker.Amplitude = 0.3f;
//_rightTracker.Amplitude = 0.3f;
}
public WebcamClient CreateRTSP()

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
@ -271,15 +272,35 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
}
public void SlideLeft()
public async void SlideLeft()
{
StopProgress();
SelectedIndex++;
await Dispatcher.InvokeAsync(async () =>
{
while (ItemsHost.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
await Task.Delay(10);
// 强制刷新布局
ItemsHost.UpdateLayout();
SelectedIndex++;
}, DispatcherPriority.ContextIdle);
}
public void SlideRight()
public async void SlideRight()
{
StopProgress();
SelectedIndex--;
await Dispatcher.InvokeAsync(async () =>
{
while (ItemsHost.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
await Task.Delay(10);
ItemsHost.UpdateLayout();
SelectedIndex--;
}, DispatcherPriority.ContextIdle);
}
}
}

View File

@ -106,16 +106,23 @@ namespace Wpf_AiSportsMicrospace
switch (wavingaction)
{
case (int)WavingAction.LeftWave: // 左手挥动
Application.Current.Dispatcher.Invoke(() => coverFlow.SlideRight());
//Application.Current.Dispatcher.Invoke(() => coverFlow.SlideRight());
coverFlow.SlideRight();
break;
case (int)WavingAction.RightWave: // 右手挥动
Application.Current.Dispatcher.Invoke(() => coverFlow.SlideLeft());
//Application.Current.Dispatcher.Invoke(() => coverFlow.SlideLeft());
coverFlow.SlideLeft();
break;
case (int)WavingAction.FirstHand: // 举手开始
//Application.Current.Dispatcher.BeginInvoke(() => coverFlow.StartSelectedProgress());
RouterGoNew();
Dispatcher.InvokeAsync(() =>
{
coverFlow.StartSelectedProgress();
}, DispatcherPriority.Render);
//RouterGoNew();
break;
case (int)WavingAction.Raising: // 举手中,实时更新进度
@ -124,7 +131,7 @@ namespace Wpf_AiSportsMicrospace
case (int)WavingAction.RaiseHand: // 举手完成
// 设置标记,停止后续手势识别
//IsGestureActive = false;
//RouterGoNew();
RouterGoNew();
//coverFlow.ProgressCompleted += CoverFlow_ProgressCompleted;
break;