Mercurial Hosting > traffic-intelligence
diff python/ubc_utils.py @ 48:8aed225f71d8
rearranged code for function readline and getlines (and characters), moved invertHomography to cvutils
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 23 Sep 2010 17:24:31 -0400 |
parents | e27598865af3 |
children | 3aed17fc468d |
line wrap: on
line diff
--- a/python/ubc_utils.py Thu Sep 23 17:12:09 2010 -0400 +++ b/python/ubc_utils.py Thu Sep 23 17:24:31 2010 -0400 @@ -6,8 +6,6 @@ __metaclass__ = type -delimiterChar = '%'; - def getFileType(s): filePrefix = utils.removeExtension(s) i = filePrefix.rfind('-') @@ -16,16 +14,7 @@ else: return '' -def getLines(f): - '''Gets a complete entry (all the lines) in between delimiterChar.''' - dataStrings = [] - s = utils.readline(f) - while (len(s) > 0) and (not s.startswith(delimiterChar)): - dataStrings += [s.strip()] - s = utils.readline(f) - return dataStrings - -def saveTrajectorieUserTypes(inFilename, outFilename, objects): +def saveTrajectoryUserTypes(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) @@ -36,7 +25,7 @@ if (not infile) | (not outfile): return - lines = getLines(file) + lines = utils.getLines(infile) objNum = 0 while lines != []: i = 0 @@ -47,6 +36,7 @@ outfile.write() # next object objNum += 1 + lines = utils.getLines(infile) def loadTrajectories(filename, nObjects = -1): '''Loads trajectories''' @@ -58,7 +48,7 @@ objects = [] objNum = 0 objectType = getFileType(filename) - lines = getLines(file) + lines = utils.getLines(file) while (lines != []) and ((nObjects<0) or (objNum<nObjects)): l = lines[0].split(' ') parsedLine = [int(n) for n in l[:4]] @@ -88,7 +78,7 @@ else: print("Error two lines of data for feature %d"%(f.num)) - lines = getLines(file) + lines = utils.getLines(file) file.close() return objects @@ -102,7 +92,7 @@ points = {} num = 0 - lines = getLines(file) + lines = utils.getLines(file) while (lines != []) and ((nPoints<0) or (num<nPoints)): parsedLine = [int(n) for n in lines[0].split(' ')] protagonistNums = (parsedLine[0], parsedLine[1]) @@ -110,7 +100,7 @@ [float(n) for n in lines[2].split(' ')]] num+=1 - lines = getLines(file) + lines = utils.getLines(file) file.close() return points