summaryrefslogtreecommitdiffstats
path: root/data/variance.py
diff options
context:
space:
mode:
Diffstat (limited to 'data/variance.py')
-rwxr-xr-xdata/variance.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/data/variance.py b/data/variance.py
new file mode 100755
index 0000000..1e234cb
--- /dev/null
+++ b/data/variance.py
@@ -0,0 +1,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()
+