ai 优化 12
This commit is contained in:
parent
a762d66b5a
commit
d157b7212b
@ -39,6 +39,7 @@ namespace Wpf_AiSportsMicrospace.Common
|
|||||||
|
|
||||||
private DateTime? _wristStartTime = null;
|
private DateTime? _wristStartTime = null;
|
||||||
private bool _firstHandTriggered = false;
|
private bool _firstHandTriggered = false;
|
||||||
|
private double? _lastRightWristX = null;
|
||||||
private double? _lastRightWristY = null;
|
private double? _lastRightWristY = null;
|
||||||
private DateTime _rightRaiseGuardUntil = DateTime.MinValue;
|
private DateTime _rightRaiseGuardUntil = DateTime.MinValue;
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ namespace Wpf_AiSportsMicrospace.Common
|
|||||||
|
|
||||||
bool wristAboveShoulder = wrist.Y <= shoulder.Y - 20;
|
bool wristAboveShoulder = wrist.Y <= shoulder.Y - 20;
|
||||||
bool wristAboveElbow = wrist.Y <= elbow.Y - 20;
|
bool wristAboveElbow = wrist.Y <= elbow.Y - 20;
|
||||||
bool closeToBody = Math.Abs(wrist.X - shoulder.X) <= 260;
|
bool closeToBody = Math.Abs(wrist.X - shoulder.X) <= 220;
|
||||||
|
|
||||||
return wristAboveShoulder && wristAboveElbow && closeToBody;
|
return wristAboveShoulder && wristAboveElbow && closeToBody;
|
||||||
}
|
}
|
||||||
@ -188,21 +189,26 @@ namespace Wpf_AiSportsMicrospace.Common
|
|||||||
private bool IsRightHandRaisingUp(Human human)
|
private bool IsRightHandRaisingUp(Human human)
|
||||||
{
|
{
|
||||||
var wrist = human.Keypoints.FirstOrDefault(k => k.Name == "right_wrist");
|
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");
|
var shoulder = human.Keypoints.FirstOrDefault(k => k.Name == "right_shoulder");
|
||||||
|
|
||||||
if (wrist == null || shoulder == null)
|
if (wrist == null || shoulder == null || elbow == null)
|
||||||
{
|
{
|
||||||
|
_lastRightWristX = null;
|
||||||
_lastRightWristY = null;
|
_lastRightWristY = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool movingUp = _lastRightWristY.HasValue && _lastRightWristY.Value - wrist.Y >= 45;
|
bool movingUp = _lastRightWristY.HasValue && _lastRightWristY.Value - wrist.Y >= 45;
|
||||||
bool closeToBody = Math.Abs(wrist.X - shoulder.X) <= 320;
|
bool movingSideways = _lastRightWristX.HasValue && Math.Abs(wrist.X - _lastRightWristX.Value) >= 80;
|
||||||
|
bool closeToBody = Math.Abs(wrist.X - shoulder.X) <= 220;
|
||||||
bool highEnough = wrist.Y <= shoulder.Y + 120;
|
bool highEnough = wrist.Y <= shoulder.Y + 120;
|
||||||
|
bool wristAboveElbow = wrist.Y <= elbow.Y - 20;
|
||||||
|
|
||||||
|
_lastRightWristX = wrist.X;
|
||||||
_lastRightWristY = wrist.Y;
|
_lastRightWristY = wrist.Y;
|
||||||
|
|
||||||
if (movingUp && closeToBody && highEnough)
|
if (movingUp && !movingSideways && closeToBody && highEnough && wristAboveElbow)
|
||||||
{
|
{
|
||||||
GuardWavesForRaise();
|
GuardWavesForRaise();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user