送检帧显示未通过结果及完成概率
This commit is contained in:
parent
7f82a1f975
commit
308941c0be
@ -66,14 +66,18 @@ public sealed partial class CameraViewModel
|
||||
if (!ReferenceEquals(_flowTest, test) || _closing) return;
|
||||
FlowTestStatus = status; FlowTestDetails = details;
|
||||
});
|
||||
test.DecisionImageCaptured += (jpeg, frameId) => _dispatcher.BeginInvoke(() =>
|
||||
test.DecisionSubmitted += request => _dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (!ReferenceEquals(_flowTest, test) || _closing) return;
|
||||
using var image = Cv2.ImDecode(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 实际送检图 · 视频帧 {frameId}";
|
||||
ShowFlowTestDecision(request, "检查中");
|
||||
});
|
||||
test.DecisionEvaluated += (request, result, accepted) => _dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (!ReferenceEquals(_flowTest, test) || _closing) return;
|
||||
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}");
|
||||
});
|
||||
await Task.Run(test.LoadModels);
|
||||
test.Start();
|
||||
@ -92,6 +96,15 @@ public sealed partial class CameraViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowFlowTestDecision(VisionDecisionRequest request, string status)
|
||||
{
|
||||
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}";
|
||||
}
|
||||
|
||||
// 仅在解码任务结束后调用,避免释放正在推理的模型。
|
||||
private async Task CompleteFlowTestAsync()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user