Mercurial Hosting > traffic-intelligence
changeset 968:32a34a143c27
work on sumo and metadata
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 07 Dec 2017 15:13:06 -0500 |
parents | 373e8ef6ee25 |
children | 5d788d2e8ffc |
files | python/metadata.py python/sumo.py tracking.cfg |
diffstat | 3 files changed, 35 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/python/metadata.py Tue Dec 05 16:15:44 2017 -0500 +++ b/python/metadata.py Thu Dec 07 15:13:06 2017 -0500 @@ -363,14 +363,16 @@ eg somedirectory/montreal/ contains intersection1, intersection2, etc. The site names would be somedirectory/montreal/intersection1, somedirectory/montreal/intersection2, etc.''' - from os import listdir, path + from os import listdir, path, sep sites = [] cameraViews = [] names = listdir(directoryName) + cameraViewIdx = 1 for name in names: - if path.isdir(directoryName+'/'+name): - sites.append(Site(directoryName+'/'+name, None)) - cameraViews.append(CameraView(-1, None, None, sites[-1], None)) + if path.isdir(directoryName+sep+name): + sites.append(Site(directoryName+sep+name, None)) + cameraViews.append(CameraView('view{}'.format(cameraViewIdx), None, sites[-1], None, None, None)) + cameraViewIdx += 1 session.add_all(sites) session.add_all(cameraViews) session.commit()
--- a/python/sumo.py Tue Dec 05 16:15:44 2017 -0500 +++ b/python/sumo.py Thu Dec 07 15:13:06 2017 -0500 @@ -3,31 +3,39 @@ http://sumo.dlr.de ''' -import csv +#import csv def loadTazEdges(inFilename): - '''Converts list of OSM edges per OSM edge and groups per TAZ''' + '''Converts list of OSM edges per OSM edge and groups per TAZ + format is csv with first two columns the OSM id and TAZ id, then the list of SUMO edge id + + Returns the list of SUMO edge per TAZ''' data = [] tazs = {} with open(inFilename,'r') as f: - csv_reader = csv.reader(f, delimiter=",") - next(csv_reader, None) # skip the headers - for row in csv_reader: - data.append(row) + f.readline() # skip the headers + for r in f: + tmp = r.strip().split(',') + tazID = tmp[1] + for edge in tmp[2:]: + if len(edge) > 0: + if tazID in tazs: + if edge not in tazs[tazID]: + tazs[tazID].append(edge) + else: + tazs[tazID] = [edge] + return tazs - for datum in data: - if len(datum) > 5 and datum[5] is not None: - tazID = datum[3] - for edge in datum[15:]: - if len(edge) > 0: - if edge is not None: - if tazID in tazs: - if edge not in tazs[tazID]: - tazs[tazID].append(edge) - else: - tazs[tazID] = [edge] - return tazs - +def edge2Taz(tazs): + '''Returns the associative array of the TAZ of each SUMO edge''' + edge2Tazs = {} + for taz, edges in tazs.iteritems(): + for edge in edges: + if edge in edge2Tazs: + print('error for edge: {} (taz {}/{})'.format(edge, edge2Tazs[edge], taz)) + edge2Tazs[edge] = taz + return edge2Tazs + def saveTazEdges(outFilename, tazs): with open(outFilename,'w') as out: out.write('<tazs>\n')
--- a/tracking.cfg Tue Dec 05 16:15:44 2017 -0500 +++ b/tracking.cfg Thu Dec 07 15:13:06 2017 -0500 @@ -51,7 +51,7 @@ pyramid-level = 5 # number of displacement to test minimum feature motion ndisplacements = 3 -# minimum displacement to keep features (px) +# minimum displacement to keep features (world distance unit or px) min-feature-displacement = 0.05 # maximum feature acceleration acceleration-bound = 3 @@ -68,7 +68,7 @@ # minimum eigen value of a 2x2 normal matrix of optical flow equations min-feature-eig-threshold = 1e-4 # minimum length of a feature (number of frames) to consider a feature for grouping -min-feature-time = 9 +min-feature-time = 15 # Min Max similarity parameters (Beymer et al. method) # connection distance in feature grouping (world distance unit or px) mm-connection-distance = 2.68813545522