-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKinectClaseUser.pde
More file actions
156 lines (114 loc) · 4.1 KB
/
Copy pathKinectClaseUser.pde
File metadata and controls
156 lines (114 loc) · 4.1 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//-----------------------Librerias-------------------
import SimpleOpenNI.*;
//------------------------Variables-------------------
SimpleOpenNI context;
////////////////////////kinect
PVector com = new PVector();
PVector com2d = new PVector();
float manoIzqX;
float manoIzqY;
float manoIzqz;
float manoDerX;
float manoDerY;
float manoDerz;
float torsoX;
float torsoY;
float torsoZ;
//------------------------Setup-------------------
void setup()
{
size(500,400);
frameRate(30);
noCursor();
//kinect
context = new SimpleOpenNI(this);
if(context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}
// enable depthMap generation
context.enableDepth();
// enable skeleton generation for all joints
context.enableUser();
}
//------------------------Draw-------------------
void draw()
{
//kinect
// update the cam
context.update();
// draw depthImageMap
image(context.depthImage(),0,0,400,300);
//image(context.userImage(),0,300,400,300);
int[] userList = context.getUsers();
for(int i=0;i<userList.length;i++)
{
//dibuja los circulos a partir de las ubicaciones del esqueleto
if(context.isTrackingSkeleton(userList[i]))
{
drawSkeleton(userList[i]);
}
// dibuja el centro de masa
if(context.getCoM(userList[i],com))
{
context.convertRealWorldToProjective(com,com2d);
}
}
ellipse(manoIzqX,manoIzqY,15,15);
ellipse(manoDerX,manoDerY,15,15);
ellipse(torsoX,torsoY,15,15);
}
void onNewUser(SimpleOpenNI curContext, int userId)
{
println("onNewUser - userId: " + userId);
println("\tstart tracking skeleton");
curContext.startTrackingSkeleton(userId);
}
void onLostUser(SimpleOpenNI curContext, int userId)
{
println("onLostUser - userId: " + userId);
}
void onVisibleUser(SimpleOpenNI curContext, int userId)
{
//println("onVisibleUser - userId: " + userId);
}
// draw the skeleton with the selected joints
void drawSkeleton(int userId)
{
PVector TorsoPos = new PVector();
println(com2d.x);
torsoX = com2d.x;
torsoY = com2d.y;
PVector manoIzqPos = new PVector();
context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_RIGHT_HAND,manoIzqPos);
//println(manoIzqPos.y);
manoIzqX = manoIzqPos.x;
manoIzqY = manoIzqPos.y;
manoIzqz = manoIzqPos.z;
PVector manoDerPos = new PVector();
context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_LEFT_HAND,manoDerPos);
//println(manoDerPos.x);
manoDerX = manoDerPos.x;
manoDerY = manoDerPos.y;
manoDerz = manoDerPos.z;
//println(manoDerz);
/*
context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);
context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);
context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);
context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);
context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);
context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);
context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);
context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);
context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);
context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);
context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);
context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);
context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);
context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);
context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);
*/
}