def getFeatureVec(fileName, chopFactor, firstRun=False, joints=None): headers = open(fileName, "r").readline().split() # bug in the files headers = jm.getFileHeader(headers) ver = jm.getVersion(headers) featuresNames = [] vec = [] jointsHeaders = headers[2:-4] for i, h in enumerate(jointsHeaders): # drop timestamp, frameNum and floor if i % 4 == 3: continue # time, relJoints = ae.getRelative2AncestorPosition(fileName, h, ver) if i % 4 != 0: continue if not joints is None and not h in joints: continue try: # for joints that don't have father and grandfather time, _, angles, _ = ae.getAngleVec(fileName, h, False, ver) if len(angles) == 0: continue except Exception, e: # joint without a father continue if firstRun: print "getAngleVec", h, len(vec) v, f = analyzeData(time, angles, h.split("_")[0] + " angle ") vec += v featuresNames += f
import utils.kinect.angleExtraction as ae import utils.stitching.stitching.quantization as qu import matplotlib.pyplot as plt import utils.oldKinectExtractor as ke import utils.stitching.stitching as st import utils.stitching.stitching.mineByPattern as mbp from numpy import linalg as LA import copy fileName = 'inputs/ran_5_2_14_840.skl' joint = 'AnkleRight_X' time, values = ae.getAngleVec(fileName, joint, True) disFactor=0.2 numOfClusters = 6 minimalCluster = 10 fracs = ke.clusterByTime(time, values, False, minimalCluster) #originalFracs = copy.deepcopy(fracs) prob = 0.05 fracs = ke.filterOutliers(fracs, False, prob) i=0 parts, kuku = ke.cleanFracs(fracs, False) pattern = [14, 15, 17, 19, 24, 28, 33, 33, 33, 33, \ 33, 33, 28, 24, 19, 17, 15, 14,\ 12, 12, 14, 15, 16, 17.5, 17.5, 17.5, \ 16, 15, 14, 13, 12, 12] i=1 framSize = 4 groupSize = framSize**2 minedParts = []
import utils.kinect.angleExtraction as ae import utils.stitching.stitching.quantization as qu import matplotlib.pyplot as plt fileName = "inputs/ran_5_2_14_840.skl" joint = "AnkleRight_X" time, angles = ae.getAngleVec(fileName, joint, True) disFactor = 0.05 numOfClusters = 12 res = qu.doRambamAlgo(time, angles, numOfClusters, disFactor) plt.figure() plt.plot(res) plt.show()
import matplotlib.pyplot as plt import utils.kinect.angleExtraction as ae import utils.oldKinectExtractor as ke import algorithm.stitching as st import numpy as np import algorithm.quantization as qu import utils.utils as pe import copy import utils.MovingAverage as ma import algorithm.partitionizing as prt from tsp_solver.greedy import solve_tsp import algorithm.mineByPattern as mp #Reading from file fileName = 'myKinect/v2RanLong.skl' joint = 'KneeLeft_X' time, frameNumbers, angles= ae.getAngleVec(fileName, joint, True, 'NEW') #Extracting clean fractions minimalCluster=20 fracs = ke.clusterByTime(time, frameNumbers, angles, False, minimalCluster) prob = 0.1 fracs = ke.filterOutliers(fracs, False, prob) i=0 cleanedParts, _ = ke.cleanFracs(fracs, False, 5, 1.5) st.plotParts(cleanedParts) #Creating pattern to mine for lenOfCycle = 35 pattern = mp.createFlippedUpattern(angles, lenOfCycle, 3) #Mining the pattern from the input
import utils.kinect.angleExtraction as ae import matplotlib.pyplot as plt import utils.oldKinectExtractor as ex import itertools import numpy as np fileName = 'inputs/alon_multi_right.skl'#'inputs/asc_gyro_l.skl' joint = 'AnkleRight_X' time, angles, weights = ae.getAngleVec(fileName, joint, False) startGrade=0.93 minimalOverlap=10 maximalOverlap=50 lengthFactor=0#-0.4 merged, des, fracs = ex.stitchKinect(time, angles, weights, True, startGrade, minimalOverlap, maximalOverlap, lengthFactor) time, values = zip(*fracs) sortingIndices = sorted(des.keys(), key=lambda k: des[k][0]) timeLine = [] for i in sortingIndices: timeLine = timeLine[:des[i][0]] + time[i] #timeLine = list(itertools.chain(*time)) mat = {} file = open(fileName, 'r') headersStr = file.readline() headers = headersStr.split() for line in file: splited = line.split() mat[float(splited[0])] = splited[1:]