Repository navigation
Expand file tree
/
Copy pathPausePoseDetector.cpp
More file actions
73 lines (63 loc) · 3.13 KB
/
Copy pathPausePoseDetector.cpp
File metadata and controls
73 lines (63 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*****************************************************************************
* *
* Unity Wrapper *
* Copyright (C) 2010 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
//Author: Shlomo Zippel
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include "PausePoseDetector.h"
#include <math.h>
//-----------------------------------------------------------------------------
// PauseGesturePoseDetector implementation
//-----------------------------------------------------------------------------
bool PauseGesturePoseDetector::IsInPose()
{
XnSkeletonJointTransformation leftHand;
XnSkeletonJointTransformation rightHand;
xn::SkeletonCapability skeletonCap = m_userGenerator.GetSkeletonCap();
// is this user even being tracked?
if (!skeletonCap.IsTracking(m_userId))
{
return false;
}
// get hands & head
skeletonCap.GetSkeletonJoint(m_userId, XnSkeletonJoint::XN_SKEL_LEFT_HAND, leftHand);
skeletonCap.GetSkeletonJoint(m_userId, XnSkeletonJoint::XN_SKEL_RIGHT_HAND, rightHand);
// make sure the points have enough confidence
if ((leftHand.position.fConfidence < 0.5) ||
(rightHand.position.fConfidence < 0.5))
{
return false;
}
// make sure hands are reversed & same height
float xDist = leftHand.position.position.X - rightHand.position.position.X;
float yDist = fabs(leftHand.position.position.Y - rightHand.position.position.Y);
if ((xDist < 60 ) ||
(yDist > 300))
{
return false;
}
return true;
}
void PauseGesturePoseDetector::Reset()
{
SkeletonPoseDetectorBase::Reset();
}