From d5165ac76dff30b8ab0e3c1add8df60780b4abe5 Mon Sep 17 00:00:00 2001 From: tfarcraw <123211521@163.com> Date: Thu, 19 Nov 2026 17:11:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=B8=A7=E6=A3=80=E6=9F=A5=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=92=8C=E6=A6=82=E7=8E=87=E5=8F=A0=E5=8A=A0=E5=88=B0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Training/CameraFlowTest.cs | 16 ++++++++++++---- .../Training/CameraViewModel.cs | 5 ++++- .../VVMs/RecipeEditor/RecipeEditor.axaml | 7 +++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/SopHelper.Avalonia/Training/CameraFlowTest.cs b/src/SopHelper.Avalonia/Training/CameraFlowTest.cs index aed9e49..40a0f36 100644 --- a/src/SopHelper.Avalonia/Training/CameraFlowTest.cs +++ b/src/SopHelper.Avalonia/Training/CameraFlowTest.cs @@ -13,6 +13,13 @@ public sealed partial class CameraViewModel private string _flowTestStatus = "", _flowTestDetails = ""; private BitmapSource? _flowTestDecisionImage; private string _flowTestDecisionLabel = ""; + private string _flowTestVideoResult = ""; + public string FlowTestVideoResult + { + get => _flowTestVideoResult; + private set { SetProperty(ref _flowTestVideoResult, value); RaisePropertyChanged(nameof(HasFlowTestVideoResult)); } + } + public bool HasFlowTestVideoResult => !string.IsNullOrEmpty(FlowTestVideoResult); private IReadOnlyDictionary? _flowTestRegions; public IReadOnlyDictionary? FlowTestRegions { @@ -49,6 +56,7 @@ public sealed partial class CameraViewModel FlowTestDetails = ""; FlowTestDecisionImage = null; FlowTestDecisionLabel = ""; + FlowTestVideoResult = ""; FlowTestStatus = "正在准备流程测试…"; try { @@ -69,7 +77,7 @@ public sealed partial class CameraViewModel test.DecisionSubmitted += request => _dispatcher.BeginInvoke(() => { if (!ReferenceEquals(_flowTest, test) || _closing) return; - ShowFlowTestDecision(request, "检查中"); + ShowFlowTestDecision(request); }); test.DecisionEvaluated += (request, result, accepted) => _dispatcher.BeginInvoke(() => { @@ -77,7 +85,7 @@ public sealed partial class CameraViewModel var probability = result.EffectiveStatus is (VisionDecisionStatus.Completed or VisionDecisionStatus.NotCompleted) && double.IsFinite(result.Confidence) && result.Confidence is >= 0 and <= 1 ? $"完成概率 {result.Confidence:P1}" : "概率不可用"; - ShowFlowTestDecision(request, $"检查{(accepted ? "通过" : "未通过")} · {probability} · {result.Reason}"); + FlowTestVideoResult = $"步骤 {request.StepId} · 送检帧 {request.FrameId}\n检查{(accepted ? "通过" : "未通过")} · {probability}"; }); await Task.Run(test.LoadModels); test.Start(); @@ -96,13 +104,13 @@ public sealed partial class CameraViewModel } } - private void ShowFlowTestDecision(VisionDecisionRequest request, string status) + private void ShowFlowTestDecision(VisionDecisionRequest request) { using var image = Cv2.ImDecode(request.Jpeg, ImreadModes.Color); var stride = checked((int)image.Step()); FlowTestDecisionImage = BitmapSource.Create(image.Width, image.Height, 96, 96, PixelFormats.Bgr24, null, image.Data, checked(stride * image.Height), stride); - FlowTestDecisionLabel = $"AI 实际送检图 · 视频帧 {request.FrameId} · {status}"; + FlowTestDecisionLabel = $"AI 实际送检图 · 视频帧 {request.FrameId}"; } // 仅在解码任务结束后调用,避免释放正在推理的模型。 diff --git a/src/SopHelper.Avalonia/Training/CameraViewModel.cs b/src/SopHelper.Avalonia/Training/CameraViewModel.cs index 8d6cf30..f4389b4 100644 --- a/src/SopHelper.Avalonia/Training/CameraViewModel.cs +++ b/src/SopHelper.Avalonia/Training/CameraViewModel.cs @@ -108,7 +108,10 @@ public sealed partial class CameraViewModel : BindableBase if (e.PropertyName is nameof(Playback.IsPlaying) or nameof(Playback.IsLoaded) or nameof(Playback.IsAtEnd)) { RaisePropertyChanged(nameof(PlayVideoButtonText)); UpdateCommands(); } if (e.PropertyName == nameof(Playback.IsLoaded)) - { RaisePropertyChanged(nameof(CanSeekVideo)); RaisePropertyChanged(nameof(ShowFlowTestOverlay)); } + { + RaisePropertyChanged(nameof(CanSeekVideo)); RaisePropertyChanged(nameof(ShowFlowTestOverlay)); + if (!Playback.IsLoaded) FlowTestVideoResult = ""; + } if (e.PropertyName == nameof(Playback.IsAtEnd) && Playback.IsAtEnd) { if (IsTestingFlow) _ = CompleteFlowTestAsync(); diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml index 03a4d6f..1fbf63a 100644 --- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml +++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml @@ -465,6 +465,7 @@ + @@ -472,6 +473,12 @@ + + + +