Mercurial Hosting > traffic-intelligence
comparison trafficintelligence/processing.py @ 1067:092bd9c7deaf
corrected bug with multiprocessing and centiles
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 16 Jul 2018 01:24:26 -0400 |
parents | 862b55a87e63 |
children | c67f8c36ebc7 |
comparison
equal
deleted
inserted
replaced
1066:862b55a87e63 | 1067:092bd9c7deaf |
---|---|
16 speeds[o.num] = np.mean(objspeeds) # km/h | 16 speeds[o.num] = np.mean(objspeeds) # km/h |
17 else: | 17 else: |
18 objectsNotInZone.append(o) | 18 objectsNotInZone.append(o) |
19 return speeds, objectsNotInZone | 19 return speeds, objectsNotInZone |
20 | 20 |
21 def extractVideoSequenceSpeeds(dbFilename, siteName, nObjects, startTime, frameRate, minUserDurationSeconds, aggFunctions): | 21 def extractVideoSequenceSpeeds(dbFilename, siteName, nObjects, startTime, frameRate, minUserDurationSeconds, aggMethods, aggCentiles): |
22 data = [] | 22 data = [] |
23 d = startTime.date() | 23 d = startTime.date() |
24 t1 = startTime.time() | 24 t1 = startTime.time() |
25 minUserDuration = minUserDurationSeconds*frameRate | 25 minUserDuration = minUserDurationSeconds*frameRate |
26 print('Extracting speed from '+dbFilename) | 26 print('Extracting speed from '+dbFilename) |
27 aggFunctions, tmpheaders = utils.aggregationMethods(aggMethods, aggCentiles) | |
27 objects = storage.loadTrajectoriesFromSqlite(dbFilename, 'object', nObjects) | 28 objects = storage.loadTrajectoriesFromSqlite(dbFilename, 'object', nObjects) |
28 for o in objects: | 29 for o in objects: |
29 if o.length() > minUserDuration: | 30 if o.length() > minUserDuration: |
30 row = [siteName, d, utils.framesToTime(o.getFirstInstant(), frameRate, t1), o.getUserType()] | 31 row = [siteName, d, utils.framesToTime(o.getFirstInstant(), frameRate, t1), o.getUserType()] |
31 tmp = o.getSpeeds() | 32 tmp = o.getSpeeds() |
32 for method,func in aggFunctions.items(): | 33 for method,func in aggFunctions.items(): |
33 aggSpeeds = frameRate*3.6*func(tmp) | 34 aggSpeeds = frameRate*3.6*func(tmp) |
34 if method == 'centile': | 35 if method == 'centile': |
35 row += aggSpeeds.tolist() | 36 row.extend(aggSpeeds.tolist()) |
36 else: | 37 else: |
37 row.append(aggSpeeds) | 38 row.append(aggSpeeds) |
38 data.append(row) | 39 data.append(row) |
39 return data | 40 return data |
40 | 41 |