Mercurial Hosting > traffic-intelligence
changeset 52:441c8387f34f
changed type detection to load trajectories
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 12 Oct 2010 18:24:11 -0400 |
parents | 3aed17fc468d |
children | 0a5bdbf0d1b4 |
files | python/ubc_utils.py |
diffstat | 1 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/python/ubc_utils.py Sat Sep 25 11:38:42 2010 -0400 +++ b/python/ubc_utils.py Tue Oct 12 18:24:11 2010 -0400 @@ -12,13 +12,20 @@ 'bus' 'truck'] +fileTypeNames = ['feature', + 'object', + 'prototype', + 'contoursequence'] + def getFileType(s): - filePrefix = utils.removeExtension(s) - i = filePrefix.rfind('-') - if i>0: - return filePrefix[i+1:] - else: - return '' + 'Finds the type in fileTypeNames' + for fileType in fileTypeNames: + if s.find(fileType)>0: + return fileType + return '' + +def isFileType(s, fileType): + return (s.find(fileType)>0) def saveTrajectoryUserTypes(inFilename, outFilename, objects): '''The program saves the objects, @@ -70,7 +77,7 @@ obj.positions = Trajectory.load(lines[1], lines[2]) if len(lines) >= 5: obj.velocities = Trajectory.load(lines[3], lines[4]) - if objectType == 'objects': + if objectType == 'object': obj.userType = parsedLine[3] obj.nObjects = float(l[4]) obj.featureNumbers = [int(n) for n in l[5:]] @@ -80,7 +87,7 @@ 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': + elif objectType == 'prototype': obj.userType = parsedLine[3] obj.nMatchings = int(l[4])