summaryrefslogtreecommitdiffstats
path: root/data/skeleton.py
blob: c5641c021d9308cc41d7a5ae3026858c10ea8dd9 (plain)
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
#!/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 = "Spine"
j2 = "HipCenter"
vals = {}
pframe = -1
X = []
Y = []
colors = ['r', 'k', 'y', 'g', 'b', 'm']
i = 0


#while 1:
#    where = sk_file.tell()
#    line = sk_file.readline()
#    if not line:
#        time.sleep(1)
#        file.seek(where)
#    else:
print sys.argv
splt = fig.add_subplot(111)
for arg in sys.argv[1:]:
    sk_file = open(arg)
    for line in sk_file.readlines():
        try:
            frame, id, joint, state, x, y, z, dx, dy = line.split(',')
        except:
            run, frame, id, joint, state, x, y, z, dx, dy = line.split(',')
        if frame != pframe and vals != {}:
            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)
                X += [dist]
                Y += [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)
    c = "%c+" % (colors[i],)
    splt.plot(X,Y,c)
    i = (i+1)%(len(colors)) 
    print c
    X = []
    Y = []
    
plt.draw()
plt.waitforbuttonpress()