审计清单无效或正反对照失败时返回失败状态

This commit is contained in:
tfarcraw 2026-11-19 02:16:35 +08:00
parent 1edcd1ce06
commit 8638f8a9aa

View File

@ -14,6 +14,7 @@ internal static class EvidenceAuditChecks
var original = File.ReadAllBytes(configPath);
var config = SopConfigLoader.Load(configPath);
var cases = JsonSerializer.Deserialize<Case[]>(File.ReadAllText(manifestPath), new JsonSerializerOptions { PropertyNameCaseInsensitive = true })!;
if (cases is null || cases.Length == 0) throw new ArgumentException("审计清单不能为空");
using var settings = JsonDocument.Parse(File.ReadAllText(settingsPath));
var root = settings.RootElement;
string Text(string key) => root.TryGetProperty(key, out var value) ? value.GetString() ?? "" : "";
@ -30,8 +31,10 @@ internal static class EvidenceAuditChecks
var frames = new List<VisionEvidenceFrame>();
foreach (var seconds in sample.Times)
{
if (!double.IsFinite(seconds) || seconds < 0 || seconds >= capture.FrameCount / capture.Fps)
throw new ArgumentException("审计证据时间超出视频范围");
var id = (long)Math.Round(seconds * capture.Fps);
capture.Set(VideoCaptureProperties.PosFrames, id);
if (!capture.Set(VideoCaptureProperties.PosFrames, id)) throw new IOException("无法定位审计原始帧");
using var image = new Mat();
if (!capture.Read(image) || image.Empty()) throw new IOException("无法读取审计证据");
var mode = VisionImageMode.Resolve(options);
@ -68,5 +71,6 @@ internal static class EvidenceAuditChecks
new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine($"审计步骤 {sample.StepId} {sample.Kind}: 正确={correct}, 放行={accepted}, 期望={sample.ExpectedCompleted}, {decision?.Reason ?? error}");
}
if (!allCorrect) throw new InvalidOperationException("正例或边界反例未通过,详见报告:" + reportPath);
}
}