Preprocessing: TRo Journal


Generate pickle files that are used in different experiments.


In [ ]:
# import the modules
import csv
import numpy as np
import cPickle as pickle

Generate Pickle Files



In [ ]:
# load all the files and create Data
trackPath = 'Data/Tracks/'
mocapPath = 'Data/MocapData/'
kinectPath = 'Data/KinectData/'

nTypes = 3
dataFormats = ['','Cloud','TopCoord']
dataKeys = ['Time','Cloud','TopCoord']
paths = [trackPath,kinectPath, mocapPath]

nPos = 6
nShr = 4
names = []
for nS in range(nShr):
    for nP in range(nPos):
        names.append('K1S%dP%dT1' % (nS+1,nP+1))

# loop over all names
Data = {}
for fileName in names:
    data = {}
    for ind in range(nTypes):
        dataName = paths[ind] + fileName + dataFormats[ind] 
        reader = csv.reader(open(dataName,"rb"), delimiter=',')

        d = np.array(list(reader))
        data[dataKeys[ind]] = d.astype('float')        
    Data[fileName] = data

# dump complete dataset to pickle file (large one)
pickle.dump(Data,open('Data/Data.p','wb'))

In [ ]:
# load all the files and create Data
trackPath = 'Data/Tracks/'
mocapPath = 'Data/MocapData/'
kinectPath = 'Data/KinectData/'

names = ['K1S1P1T1','K1S1P2T1','K1S1P3T1','K1S1P4T1','K1S1P5T1','K1S1P6T1']

nTypes = 9

dataFormats = ['','ESF','Cloud','Color','Depth','Marker','CircleParam','CircleMarker','TopCoord']
dataKeys = ['Time','ESF','Cloud','Color','Depth','Marker','CircleParam','CircleMarker','TopCoord']

paths = [trackPath, kinectPath, kinectPath, kinectPath, kinectPath, mocapPath, mocapPath, mocapPath, mocapPath]

# read all the file names and save to dicts
Data = {}
# loop over all names
for fileName in names:
    data = {}
    for ind in range(nTypes):
        dataName = paths[ind] + fileName + dataFormats[ind] 
        reader = csv.reader(open(dataName,"rb"), delimiter=',')

        d = np.array(list(reader))
        if ind in [3,4]:
            data[dataKeys[ind]] = d.astype('int')
        else:
            data[dataKeys[ind]] = d.astype('float')        
    Data[fileName] = data
pickle.dump(Data,open('Data/FeatureData.p','wb'))