页面跳转

This commit is contained in:
tanglong 2025-09-26 12:12:35 +08:00
parent 1ca82f99a6
commit 638f039aab

View File

@ -87,14 +87,18 @@ namespace Wpf_AiSportsMicrospace
// 停止抽帧线程/释放资源 // 停止抽帧线程/释放资源
try try
{ {
_webcamClient?.StopExtract(); // 停止抽帧 _cts.Cancel(); // 停止后台处理线程
_webcamClient = null; // 释放引用 _webcamClient?.StopExtract(); // 停止摄像头抽帧
_webcamClient = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"停止抽帧异常: {ex.Message}"); Debug.WriteLine($"停止抽帧异常: {ex.Message}");
} }
// 解绑事件,防止重复触发
coverFlow.ProgressCompleted -= CoverFlow_ProgressCompleted;
// 根据图片跳转新窗口 // 根据图片跳转新窗口
string uri = item.ImageUri.ToString(); string uri = item.ImageUri.ToString();
Window newWindow = null; Window newWindow = null;
@ -134,7 +138,6 @@ namespace Wpf_AiSportsMicrospace
}, _cts.Token); }, _cts.Token);
} }
private void ProcessFrame(VideoFrame frame) private void ProcessFrame(VideoFrame frame)
{ {
try try
@ -159,6 +162,13 @@ namespace Wpf_AiSportsMicrospace
//检测挥手动作 //检测挥手动作
var wavingaction = _sportOperate.VerifyWavingAction(human); var wavingaction = _sportOperate.VerifyWavingAction(human);
if (wavingaction == (int)WavingAction.Raising)
{
return;
}
else
{
switch (wavingaction) switch (wavingaction)
{ {
case (int)WavingAction.LeftWave: // 1 case (int)WavingAction.LeftWave: // 1
@ -168,6 +178,7 @@ namespace Wpf_AiSportsMicrospace
Dispatcher.BeginInvoke(() => coverFlow.SlideRight()); Dispatcher.BeginInvoke(() => coverFlow.SlideRight());
break; break;
case (int)WavingAction.RaiseHand: // 3 举手完成 case (int)WavingAction.RaiseHand: // 3 举手完成
coverFlow.ProgressCompleted -= CoverFlow_ProgressCompleted;
coverFlow.ProgressCompleted += CoverFlow_ProgressCompleted; coverFlow.ProgressCompleted += CoverFlow_ProgressCompleted;
break; break;
case (int)WavingAction.Raising: // 4 举手中 case (int)WavingAction.Raising: // 4 举手中
@ -176,10 +187,9 @@ namespace Wpf_AiSportsMicrospace
Dispatcher.BeginInvoke(() => coverFlow.StartSelectedProgress()); Dispatcher.BeginInvoke(() => coverFlow.StartSelectedProgress());
break; break;
default: default:
Dispatcher.BeginInvoke(() => coverFlow.CancelSelectedProgress());
break; break;
} }
}
} }
catch (Exception ex) catch (Exception ex)
{ {