Mercurial Hosting > traffic-intelligence
changeset 51:3aed17fc468d
utils to save object types
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sat, 25 Sep 2010 11:38:42 -0400 |
parents | 7b06d649122b |
children | 441c8387f34f |
files | python/ubc_utils.py |
diffstat | 1 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
diff -r 7b06d649122b -r 3aed17fc468d python/ubc_utils.py --- a/python/ubc_utils.py Sat Sep 25 11:36:37 2010 -0400 +++ b/python/ubc_utils.py Sat Sep 25 11:38:42 2010 -0400 @@ -6,6 +6,12 @@ __metaclass__ = type +userTypeNames = ['car', + 'pedestrian', + 'twowheels', + 'bus' + 'truck'] + def getFileType(s): filePrefix = utils.removeExtension(s) i = filePrefix.rfind('-') @@ -20,9 +26,9 @@ from the inFilename, and saving the characteristics in objects (first line) into outFilename''' infile = utils.openCheck(inFilename) - outfile = utils.openCheck(outFilename) + outfile = utils.openCheck(outFilename,'w') - if (not infile) | (not outfile): + if (inFilename.find('features') >= 0) or (not infile) or (not outfile): return lines = utils.getLines(infile) @@ -33,11 +39,17 @@ i+=1 if i<len(objects): l = lines[0].split(' ') - outfile.write() + l[3] = str(objects[i].userType) + outfile.write(' '.join(l)+'\n') + for l in lines[1:]: + outfile.write(l+'\n') + outfile.write(utils.delimiterChar+'\n') # next object objNum += 1 lines = utils.getLines(infile) + print('read {0} objects'.format(objNum)) + def loadTrajectories(filename, nObjects = -1): '''Loads trajectories'''