ai优化6

This commit is contained in:
tanglong 2026-05-13 11:11:05 +08:00
parent 309c5678c4
commit 6c9f7ffab6

View File

@ -119,7 +119,16 @@ namespace Wpf_AiSportsMicrospace.Common
// ---- 右手举手优先 ---- // ---- 右手举手优先 ----
int rightHandAction = DetectRightHandRaise(target); int rightHandAction = DetectRightHandRaise(target);
if (rightHandAction != (int)WavingAction.None) if (rightHandAction != (int)WavingAction.None)
{
ResetWaveCounts();
return rightHandAction; return rightHandAction;
}
if (IsRightHandRaiseIntent(target))
{
ResetWaveCounts();
return (int)WavingAction.None;
}
// ---- 左右挥手累加 ---- // ---- 左右挥手累加 ----
int leftValue = _leftTracker.Tracking(target); int leftValue = _leftTracker.Tracking(target);
@ -130,19 +139,43 @@ namespace Wpf_AiSportsMicrospace.Common
if (_leftWaveCount >= WaveThreshold) if (_leftWaveCount >= WaveThreshold)
{ {
_leftWaveCount = 0; ResetWaveCounts();
return (int)WavingAction.LeftWave; return (int)WavingAction.LeftWave;
} }
if (_rightWaveCount >= WaveThreshold) if (_rightWaveCount >= WaveThreshold)
{ {
_rightWaveCount = 0; ResetWaveCounts();
return (int)WavingAction.RightWave; return (int)WavingAction.RightWave;
} }
return (int)WavingAction.None; return (int)WavingAction.None;
} }
private void ResetWaveCounts()
{
_leftWaveCount = 0;
_rightWaveCount = 0;
}
private static bool IsRightHandRaiseIntent(Human human)
{
var wrist = human.Keypoints.FirstOrDefault(k => k.Name == "right_wrist");
var elbow = human.Keypoints.FirstOrDefault(k => k.Name == "right_elbow");
var shoulder = human.Keypoints.FirstOrDefault(k => k.Name == "right_shoulder");
if (wrist == null)
return false;
if (shoulder != null && wrist.Y <= shoulder.Y + 40)
return true;
if (elbow != null && wrist.Y <= elbow.Y - 20)
return true;
return false;
}
/// <summary> /// <summary>
/// 优化后的右手举手检测 /// 优化后的右手举手检测
/// </summary> /// </summary>