diff --git a/README.md b/README.md
index a0b8402..321b13a 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ pwsh -File tools/Start-HandAiD3.ps1
## 操作流程
1. 在“运行设置”中选择 UVC 或海康相机,新建或选择配方。设置页保留相机、配方和抽帧参数。
-2. 配方编辑器包含“步骤、区域、全局设置、SOP流程视频、Agent助手”五页。在原始相机画面上绘制区域;相机设置独立于配方,在“运行设置”中点击相机后面的“配置”按钮打开专用窗口。USB 分辨率、目标帧率、视频格式和曝光补偿使用下拉菜单选择,列表提供常用配置,不代表设备均支持;海康相机可设置曝光时间。设置按设备保存在 workspace/camera-settings.json,保存后下次开启采集、取图或录像预览时生效。SOP 日志显示驱动回读模式,状态栏分别显示 USB 实测采集和渲染 fps。曝光补偿以 EV 为单位,负值压低自动曝光;选择“不修改”保留当前值,0 EV 清除补偿。当前通过 Windows MSMF 对应设备的 KS 扩展接口写入并回读确认,不支持的设备、步长或平台会明确报错;可改回“不修改”继续采集。
+2. 配方编辑器包含“步骤、区域、全局设置、SOP流程视频、Agent助手”五页。在原始相机画面上绘制区域;相机设置独立于配方,在“运行设置”中点击相机后面的“配置”按钮打开专用窗口。USB 分辨率、目标帧率、视频格式和曝光补偿使用下拉菜单选择,列表提供常用配置,不代表设备均支持;海康相机可设置曝光时间。设置按设备保存在 workspace/camera-settings.json,保存后下次开启采集、取图或录像预览时生效。SOP 日志显示驱动回读模式,状态栏分别显示 USB 实测采集和渲染 fps。曝光补偿以 EV 为单位,负值压低自动曝光;选择“不修改”保留当前值,0 EV 清除补偿。当前通过 Windows MSMF 对应设备的 KS 扩展接口写入并回读确认,不支持的设备、步长或平台,以及曝光补偿设置失败时,均静默跳过,不提示、不阻断采集。
3. 步骤名描述操作,“说明”填写送检单帧能看到的静态完成状态,AI 用说明判断图片。触发规则支持手在区域内、手进入后离开区域、A→B 移动和持续计时。
4. 送检可选整张画面、固定区域或跟随手部;跟随手部可以设置扩展距离、最小范围和位置保留时间。
5. 保存、应用后开始采集。规则满足只触发送图;AI 确认且完成概率达标后才推进。步骤说明为空、接口失败或证据不足时不会按规则直接完成。
diff --git a/src/SopHelper.Avalonia/VVMs/CameraSettings/CameraSettingsWindow.axaml b/src/SopHelper.Avalonia/VVMs/CameraSettings/CameraSettingsWindow.axaml
index 772173e..e85b2c7 100644
--- a/src/SopHelper.Avalonia/VVMs/CameraSettings/CameraSettingsWindow.axaml
+++ b/src/SopHelper.Avalonia/VVMs/CameraSettings/CameraSettingsWindow.axaml
@@ -25,7 +25,7 @@
-
+
diff --git a/src/SopHelper.CrossPlatform.Engine/Camera/UvcCameraService.cs b/src/SopHelper.CrossPlatform.Engine/Camera/UvcCameraService.cs
index ecd29ff..1b2bee6 100644
--- a/src/SopHelper.CrossPlatform.Engine/Camera/UvcCameraService.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Camera/UvcCameraService.cs
@@ -146,13 +146,11 @@ public class UvcCameraService : ICameraService
if (options.Height is { } height) Set(VideoCaptureProperties.FrameHeight, height, "高度");
if (options.Fps is { } fps) Set(VideoCaptureProperties.Fps, fps, "目标帧率");
var exposureDescription = "";
- if (options.ExposureCompensationEv is { } ev)
- {
- if (!OperatingSystem.IsWindows() || capture.Get(VideoCaptureProperties.Backend) != (double)VideoCaptureAPIs.MSMF)
- throw new NotSupportedException("曝光补偿目前需要 Windows MSMF 采集后端;请在相机配置中选择“不修改”继续采集");
- var actualEv = WindowsExposureCompensation.Set(Current?.Index ?? throw new InvalidOperationException("相机未连接"), ev);
+ if (options.ExposureCompensationEv is { } ev && OperatingSystem.IsWindows()
+ && capture.Get(VideoCaptureProperties.Backend) == (double)VideoCaptureAPIs.MSMF
+ && Current is { } current
+ && WindowsExposureCompensation.TrySet(current.Index, ev) is { } actualEv)
exposureDescription = $";曝光补偿回读 {actualEv:+0.##;-0.##;0} EV";
- }
var actualWidth = capture.Get(VideoCaptureProperties.FrameWidth);
var actualHeight = capture.Get(VideoCaptureProperties.FrameHeight);
var actualFps = capture.Get(VideoCaptureProperties.Fps);
diff --git a/src/SopHelper.CrossPlatform.Engine/Camera/WindowsExposureCompensation.cs b/src/SopHelper.CrossPlatform.Engine/Camera/WindowsExposureCompensation.cs
index 0aaf0f0..647217d 100644
--- a/src/SopHelper.CrossPlatform.Engine/Camera/WindowsExposureCompensation.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Camera/WindowsExposureCompensation.cs
@@ -13,7 +13,14 @@ internal static unsafe class WindowsExposureCompensation
private static readonly Guid VideoCapture = new("8AC3587A-4AE7-42D8-99E0-0A6013EEF90F");
private static readonly Guid SymbolicLink = new("58F0AAD8-22BF-4F8A-BB3D-D2C4978C6E2F");
- public static double Set(int index, double ev)
+ /// 曝光补偿是可选功能,驱动不支持或应用失败时静默跳过。
+ public static double? TrySet(int index, double ev)
+ {
+ try { return Set(index, ev); }
+ catch (Exception) { return null; }
+ }
+
+ private static double Set(int index, double ev)
{
if (!OperatingSystem.IsWindows()) throw new NotSupportedException("当前平台尚不支持 USB 曝光补偿");
using var device = OpenDevice(index);
diff --git a/tests/Avalonia.Smoke/Program.cs b/tests/Avalonia.Smoke/Program.cs
index d1084a6..6ca9d9f 100644
--- a/tests/Avalonia.Smoke/Program.cs
+++ b/tests/Avalonia.Smoke/Program.cs
@@ -597,6 +597,8 @@ internal static class Smoke
var rejectedRange=false;try{thirds.Encode(-3);}catch(ArgumentOutOfRangeException){rejectedRange=true;}
Check(rejectedRange,"Requested EV is checked against the actual device range");
var native=typeof(UvcCameraService).Assembly.GetType("SopHelper.Engine.Camera.WindowsExposureCompensation")!;
+ Check(native.GetMethod("TrySet")!.Invoke(null,[-1,-1d]) is null,
+ "Unavailable exposure compensation silently returns without throwing or writing to a camera");
Check(System.Runtime.InteropServices.Marshal.SizeOf(native.GetNestedType("EvPayload",System.Reflection.BindingFlags.NonPublic)!)==56,
"Native EV payload layout matches the Windows SDK");
var lifetime=(IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!;