-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
83 lines (64 loc) · 2.38 KB
/
test.py
File metadata and controls
83 lines (64 loc) · 2.38 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
#!/usr/bin/python
# -*- coding: utf-8 -*-
from nite2 import *
import time
NiTE.initialize()
tracker = UserTracker()
tracker.create()
def USER_MESSAGE(m):
print m
g_visibleUsers={}
g_skeletonStates={}
def updateUserState( user, ts):
if user.isNew():
USER_MESSAGE("New")
elif (user.isVisible() and not g_visibleUsers[user.getId()]):
USER_MESSAGE("Visible")
elif (not user.isVisible() and g_visibleUsers[user.getId()]):
USER_MESSAGE("Out of Scene")
elif (user.isLost()):
USER_MESSAGE("Lost")
g_visibleUsers[user.getId()] = user.isVisible();
#if (g_skeletonStates[user.getId()] != user.getSkeleton().getState()):
#switch(g_skeletonStates[user.getId()] = user.getSkeleton().getState())
#{
#case nite::SKELETON_NONE:
#USER_MESSAGE("Stopped tracking.")
#break;
#case nite::SKELETON_CALIBRATING:
#USER_MESSAGE("Calibrating...")
#break;
#case nite::SKELETON_TRACKED:
#USER_MESSAGE("Tracking!")
#break;
#case nite::SKELETON_CALIBRATION_ERROR_NOT_IN_POSE:
#case nite::SKELETON_CALIBRATION_ERROR_HANDS:
#case nite::SKELETON_CALIBRATION_ERROR_LEGS:
#case nite::SKELETON_CALIBRATION_ERROR_HEAD:
#case nite::SKELETON_CALIBRATION_ERROR_TORSO:
#USER_MESSAGE("Calibration Failed... :-|")
#break;
#}
#}
#}
while(True):
f = tracker.readFrame()
users=f.getUsers()
#print users
for uid in users:
user = f.getUserById(uid)
uid=user.getId()
updateUserState(user, f.getTimestamp());
if user.isNew():
print("New user id %d !" % uid)
tracker.startSkeletonTracking(uid)
elif user.getSkeleton().getState() == SkeletonState.SKELETON_TRACKED:
head = user.getSkeleton().getJoint(JointType.JOINT_HEAD)
print("User {} : {}".format(uid, head.getPosition()))
print user.getSkeleton().getState()
#else:
#if user.isVisible():
#head = user.getSkeleton().getJoint(JointType.JOINT_HEAD)
#print("User {} : {}".format(uid, head.getPosition()))
tracker.destroy()
NiTE.shutdown()