# HG changeset patch # User Nicolas Saunier # Date 1285276329 14400 # Node ID e27598865af3cadfe41d29794e98b8ea0a667868 # Parent b5d007612e16834d054573ff32e8dbc0b58f72d6 modified loadtrajectories to load objects and prototypes diff -r b5d007612e16 -r e27598865af3 python/ubc_utils.py --- a/python/ubc_utils.py Fri Aug 06 19:45:47 2010 -0400 +++ b/python/ubc_utils.py Thu Sep 23 17:12:09 2010 -0400 @@ -8,6 +8,14 @@ delimiterChar = '%'; +def getFileType(s): + filePrefix = utils.removeExtension(s) + i = filePrefix.rfind('-') + if i>0: + return filePrefix[i+1:] + else: + return '' + def getLines(f): '''Gets a complete entry (all the lines) in between delimiterChar.''' dataStrings = [] @@ -17,6 +25,29 @@ s = utils.readline(f) return dataStrings +def saveTrajectorieUserTypes(inFilename, outFilename, objects): + '''The program saves the objects, + by just copying the corresponding trajectory and velocity data + from the inFilename, and saving the characteristics in objects (first line) + into outFilename''' + infile = utils.openCheck(inFilename) + outfile = utils.openCheck(outFilename) + + if (not infile) | (not outfile): + return + + lines = getLines(file) + objNum = 0 + while lines != []: + i = 0 + while (i= 5: obj.velocities = Trajectory.load(lines[3], lines[4]) - if (isObjectFile): + if objectType == 'objects': obj.userType = parsedLine[3] obj.nObjects = float(l[4]) obj.featureNumbers = [int(n) for n in l[5:]] @@ -47,6 +78,9 @@ obj.contourType = utils.line2Floats(lines[6]) obj.contourOrigins = Trajectory.load(lines[7], lines[8]) obj.contourSizes = Trajectory.load(lines[9], lines[10]) + elif objectType == 'prototypes': + obj.userType = parsedLine[3] + obj.nMatchings = int(l[4]) if len(lines) != 2: objects.append(obj)