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
|
#!/usr/bin/python
import time
import sys
import math
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(1)
#sk_file = open(sys.argv[1])
j1 = "rhip"
j2 = "lhip"
vals = {}
pframe = -1
X = []
Y = []
limbs = (('Head','ShoulderCenter'),('ShoulderCenter','ShoulderLeft'),('ShoulderLeft','ElbowLeft'),('ElbowLeft','WristLeft'),('ShoulderCenter','ShoulderRight'),('ShoulderRight','ElbowRight'),('ElbowRight','WristRight'),\
('ShoulderCenter','Spine'),('Spine','HipCenter'),('HipCenter','HipLeft'),('HipLeft','KneeLeft'),('KneeLeft','AnkleLeft'),('HipCenter','HipRight'),('HipRight','KneeRight'),('KneeRight','AnkleRight'))
xlabels = ('h-sc','sc-sl','sl-el','el-wr','sc-sr','sr-er','er-wr','sc-s','s-hc','hc-hl','hl-kl','kl-al','hc-hr','hr-kr','kr-ar')
data = {}
colors = ['m', 'y', 'g', 'b']
#while 1:
# where = sk_file.tell()
# line = sk_file.readline()
# if not line:
# time.sleep(1)
# file.seek(where)
# else:
splt = fig.add_subplot(111)
print sys.argv
for arg in sys.argv[1:]:
name = arg.split('/')[-2].split('-')[1]
print name
if name not in data:
data[name] = []
for i in range(len(xlabels)):
data[name] += [[]]
sk_file = open(arg)
for line in sk_file.readlines():
frame, id, joint, state, x, y, z, dx, dy = line.split(',')
if frame != pframe and vals != {}:
for l in range(len(limbs)):
j1, j2 = limbs[l]
if j1 in vals and j2 in vals:
dx = vals[j1][0] - vals[j2][0]
dy = vals[j1][1] - vals[j2][1]
dz = vals[j1][2] - vals[j2][2]
limb = math.sqrt(dx*dx + dy*dy + dz*dz)
#dist = math.fabs((dz + 2*vals[j2][2])/2)
#if limb < 1000 and limb > 100:
#X += [dist]
data[name][l] += [limb]
#print str(dist) + " " + str(limb)
#print str(dist) + "\t" + str(limb)
vals = {}
if frame != 'Frame':
vals[joint] = [float(x), float(y), float(z)]
pframe = frame
#plt.figure(1)
#splt.plot(X,Y, + '+')
people = data.keys()
for i in range(len(people)):
bp = plt.boxplot(data[people[i]], sym='')
plt.setp(bp['boxes'], color=colors[i%len(colors)])
plt.setp(bp['whiskers'], color=colors[i%len(colors)])
#splt.boxplot(data)
splt.set_xticklabels(xlabels)
plt.draw()
while(1):
plt.waitforbuttonpress()
|