手势
This commit is contained in:
parent
eff2b76183
commit
bbc0291fed
@ -22,6 +22,24 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
public class SportOperate
|
||||
{
|
||||
private DateTime _lastSlideTime = DateTime.MinValue;
|
||||
|
||||
IPointTracker _leftTracker;
|
||||
IPointTracker _rightTracker;
|
||||
IPointTracker _leftElbow;
|
||||
IPointTracker _rightElbow;
|
||||
|
||||
public SportOperate()
|
||||
{
|
||||
_leftTracker = PostureCalculate.CreatePointTracker("left_wrist", 0);
|
||||
_rightTracker = PostureCalculate.CreatePointTracker("right_wrist", 0);
|
||||
_leftElbow = PostureCalculate.CreatePointTracker("left_elbow", 0);
|
||||
_rightElbow = PostureCalculate.CreatePointTracker("right_elbow", 0);
|
||||
|
||||
_leftTracker.Amplitude = 0.05f;
|
||||
_rightTracker.Amplitude = 0.05f;
|
||||
_leftElbow.Amplitude = 0.05f;
|
||||
_rightElbow.Amplitude = 0.05f;
|
||||
}
|
||||
public WebcamClient CreateRTSP()
|
||||
{
|
||||
WebcamClient webcamClient = WebcamClient.CreateRTSP("192.168.3.64", "admin", "yd708090", 554u);
|
||||
@ -34,16 +52,6 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
/// <param name="human"></param>
|
||||
public int VerifyWavingAction(Human human)
|
||||
{
|
||||
IPointTracker _leftTracker = PostureCalculate.CreatePointTracker("left_wrist", 0);
|
||||
IPointTracker _rightTracker = PostureCalculate.CreatePointTracker("right_wrist", 0);
|
||||
IPointTracker _leftElbow = PostureCalculate.CreatePointTracker("left_elbow", 0);
|
||||
IPointTracker _rightElbow = PostureCalculate.CreatePointTracker("right_elbow", 0);
|
||||
|
||||
_leftTracker.Amplitude = 0.05f;
|
||||
_rightTracker.Amplitude = 0.05f;
|
||||
_leftElbow.Amplitude = 0.05f;
|
||||
_rightElbow.Amplitude = 0.05f;
|
||||
|
||||
var leftResult = _leftTracker.Tracking(human);
|
||||
var rightResult = _rightTracker.Tracking(human);
|
||||
var leftElbowResult = _leftElbow.Tracking(human);
|
||||
@ -63,12 +71,6 @@ namespace Wpf_AiSportsMicrospace.Common
|
||||
|
||||
public int VerifyLiftHandAction(Human human)
|
||||
{
|
||||
IPointTracker _rightTracker = PostureCalculate.CreatePointTracker("right_wrist", 0);
|
||||
IPointTracker _rightElbow = PostureCalculate.CreatePointTracker("right_elbow", 0);
|
||||
|
||||
_rightTracker.Amplitude = 0.05f;
|
||||
_rightElbow.Amplitude = 0.05f;
|
||||
|
||||
var rightResult = _rightTracker.Tracking(human);
|
||||
var rightElbowResult = _rightElbow.Tracking(human);
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ namespace Wpf_AiSportsMicrospace
|
||||
private SportBase _sport;
|
||||
private readonly SportDetectionQueue _detectQueue;
|
||||
private WebcamClient _webcamClient;
|
||||
private DateTime _lastSlideTime = DateTime.MinValue;
|
||||
|
||||
private SportOperate _sportOperate;
|
||||
|
||||
@ -98,37 +97,44 @@ namespace Wpf_AiSportsMicrospace
|
||||
if (humans == null || humans.Count == 0)
|
||||
return;
|
||||
|
||||
var human = humans
|
||||
.Where(h =>
|
||||
h.Keypoints.Any(kp => kp.Name == "left_ankle" && kp.X < 1020 && kp.Y > 900 && kp.Y < 1020) &&
|
||||
h.Keypoints.Any(kp => kp.Name == "right_ankle" && kp.X > 750 && kp.Y > 900 && kp.Y < 1020)
|
||||
)
|
||||
.FirstOrDefault();
|
||||
//var human = humans
|
||||
// .Where(h =>
|
||||
// h.Keypoints.Any(kp => kp.Name == "left_ankle" && kp.X < 1020 && kp.Y > 900 && kp.Y < 1020) &&
|
||||
// h.Keypoints.Any(kp => kp.Name == "right_ankle" && kp.X > 750 && kp.Y > 900 && kp.Y < 1020)
|
||||
// )
|
||||
// .FirstOrDefault();
|
||||
|
||||
//human = humans.FirstOrDefault();
|
||||
var human = humans.FirstOrDefault();
|
||||
|
||||
if (human == null) return;
|
||||
|
||||
//检测挥手动作
|
||||
var wavingAction = _sportOperate.VerifyWavingAction(human);
|
||||
// 根据手势结果选择滑动方向
|
||||
if (wavingAction == 1)
|
||||
{
|
||||
SlideCoverFlow(coverFlow.SlideRight);
|
||||
}
|
||||
if (wavingAction == 2)
|
||||
{
|
||||
SlideCoverFlow(coverFlow.SlideLeft);
|
||||
}
|
||||
|
||||
// 启动进度条动画;
|
||||
//SlideCoverFlow(coverFlow.StartSelectedProgress);
|
||||
|
||||
////检测挥手动作
|
||||
//var wavingAction = _sportOperate.VerifyWavingAction(human);
|
||||
//// 根据手势结果选择滑动方向
|
||||
//if (wavingAction == 1)
|
||||
//{
|
||||
// SlideCoverFlow(coverFlow.SlideRight);
|
||||
// return;
|
||||
//}
|
||||
//if (wavingAction == 2)
|
||||
//{
|
||||
// SlideCoverFlow(coverFlow.SlideLeft);
|
||||
// return;
|
||||
//}
|
||||
|
||||
//检测举手动作
|
||||
var liftHandAction = _sportOperate.VerifyLiftHandAction(human);
|
||||
|
||||
// 根据手势结果选择滑动方向
|
||||
if (wavingAction == 1)
|
||||
// 根据手势结果
|
||||
if (liftHandAction == 1)
|
||||
{
|
||||
// 启动进度条动画;
|
||||
SlideCoverFlow(coverFlow.StartSelectedProgress);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -153,11 +159,5 @@ namespace Wpf_AiSportsMicrospace
|
||||
}
|
||||
}), System.Windows.Threading.DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 启动进度条动画;
|
||||
SlideCoverFlow(coverFlow.StartSelectedProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user