Repository navigation
Expand file tree
/
Copy pathSkeletonPoseDetector.cpp
More file actions
87 lines (78 loc) · 3.08 KB
/
Copy pathSkeletonPoseDetector.cpp
File metadata and controls
87 lines (78 loc) · 3.08 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*****************************************************************************
* *
* 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 "SkeletonPoseDetector.h"
//-----------------------------------------------------------------------------
// SkeletonPoseDetectorBase Implementation
//-----------------------------------------------------------------------------
void SkeletonPoseDetectorBase::Update()
{
// are we in the pose now?
if (IsInPose())
{
// take note of start time, if we haven't yet
if (m_startTime == 0.0)
{
m_startTime = Now();
}
if (0.0 == m_timeInPose)
{
m_detectionProgress = 1.0;
}
else
{
m_detectionProgress = (Now() - m_startTime) / m_timeInPose;
if (m_detectionProgress > 1.0) m_detectionProgress = 1.0;
}
}
// not in pose
else
{
// subtract some of our detection progress - this will smooth out
// cases when we ocassionally miss a few frames but still in the pose
if (m_detectionProgress > 0.04)
{
m_detectionProgress -= 0.04;
}
else
{
m_detectionProgress = 0.0;
m_startTime = 0.0;
}
}
}
double SkeletonPoseDetectorBase::GetDetectionProgress()
{
return m_detectionProgress;
}
void SkeletonPoseDetectorBase::Reset()
{
m_startTime = 0.0;
m_detectionProgress = 0.0;
}
double SkeletonPoseDetectorBase::Now()
{
return GetTickCount() / 1000.0;
}