-
Notifications
You must be signed in to change notification settings - Fork 1
/
stripframe.py
49 lines (40 loc) · 952 Bytes
/
stripframe.py
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
import glob
import os
import shutil
#Just change directory on line 11 to cut frames
def getfilelist(f=None):
"""Reads in meta data"""
if (f==None):
os.chdir("data/5/")
kin = []
meta = []
accel = []
for file in glob.glob("kin_*.txt"):
kin.append(file)
for file in glob.glob("meta_*.txt"):
meta.append(file)
for file in glob.glob("accel_*.txt"):
accel.append(file)
#print "Kin is: "+str(kin)
#print "Meta is: "+str(meta)
return (kin,meta,accel)
def framecut(f):
FCUT = 150;
"""cut out beginning and end frames"""
kindata = open(f[0],'r')
lines = kindata.readlines()
kindata.close()
flength = len(lines)
print flength
lines = lines[::(flength-FCUT)]
# lines = lines[FCUT::]
flength = len(lines)
print flength
kindata = open(f[0],'w')
for line in lines:
kindata.write(line);
kindata.close
if __name__ == '__main__':
print "Cleaning Kinect Frame Data...."
kin,meta,accel = getfilelist()
framecut(kin)