fix: 将手部检测置信度门槛降至40%
This commit is contained in:
parent
3a1b315225
commit
e98b669a7c
@ -44,6 +44,7 @@ dotnet build SopHelper.slnx
|
||||
运行时,检测到的手会直接标在视频画面上:21 个关键点与骨架连线,不显示手部外框或文字标签。
|
||||
标记与 ROI 共用原图坐标,随预览一起缩放;未检测到手或停止采集时清除。
|
||||
需要 `models/` 中的 palm 与 landmark 两份模型,缺失时日志会提示。
|
||||
手掌检测与手部关键点确认的默认置信度门槛均为 40%(界面上的置信度滑块用于 YOLO 目标检测)。
|
||||
默认支持同帧显示两只手。针对 palm 导出中内置的单手 NMS 限制,加载时仅在内存中
|
||||
适配候选输出数量,原始模型文件不变;相邻手部去重使用原始手掌框。
|
||||
|
||||
|
||||
@ -25,8 +25,11 @@ public class MediaPipeHandDetector : IDisposable
|
||||
private InferenceSession? _palm;
|
||||
private InferenceSession? _landmark;
|
||||
|
||||
private float _palmThreshold = 0.5f;
|
||||
private float _keypointThreshold = 0.5f;
|
||||
public const float DefaultPalmThreshold = 0.4f;
|
||||
public const float DefaultKeypointThreshold = 0.4f;
|
||||
|
||||
private float _palmThreshold = DefaultPalmThreshold;
|
||||
private float _keypointThreshold = DefaultKeypointThreshold;
|
||||
private int _maxHands = 2;
|
||||
|
||||
/// <summary>模型是否就绪(缺文件时上层跳过手部判定,不报错)</summary>
|
||||
|
||||
@ -105,7 +105,8 @@ public class DetectionPipeline : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
_hand.SetThresholds(0.5f, 0.5f, Math.Max(1, options.MaxHands));
|
||||
_hand.SetThresholds(MediaPipeHandDetector.DefaultPalmThreshold,
|
||||
MediaPipeHandDetector.DefaultKeypointThreshold, Math.Max(1, options.MaxHands));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -24,9 +24,9 @@ for (var index = 0; index < 300 && video.Read(frame); index++)
|
||||
if (!hands.Any(h => h.HandType == HandType.Left) || !hands.Any(h => h.HandType == HandType.Right))
|
||||
continue;
|
||||
Console.WriteLine($"PASS: 帧 {index} 同时检出左手和右手,均有 21 个关键点");
|
||||
detector.SetThresholds(0.5f, 0.5f, 1);
|
||||
detector.SetThresholds(MediaPipeHandDetector.DefaultPalmThreshold, MediaPipeHandDetector.DefaultKeypointThreshold, 1);
|
||||
if (detector.Detect(frame).Count != 1) throw new Exception("MaxHands=1 未生效");
|
||||
detector.SetThresholds(0.5f, 0.5f, 2);
|
||||
detector.SetThresholds(MediaPipeHandDetector.DefaultPalmThreshold, MediaPipeHandDetector.DefaultKeypointThreshold, 2);
|
||||
if (detector.Detect(frame).Count != 2) throw new Exception("MaxHands=2 未生效");
|
||||
Console.WriteLine("PASS: MaxHands=1/2 均生效");
|
||||
found = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user