Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/processing.py @ 1074:b123fa0e5440
merged
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 20 Jul 2018 16:24:30 -0400 |
| parents | c67f8c36ebc7 |
| children |
comparison
equal
deleted
inserted
replaced
| 1073:8ab92ee3cbef | 1074:b123fa0e5440 |
|---|---|
| 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, aggMethods, aggCentiles): | 21 def extractVideoSequenceSpeeds(dbFilename, siteName, nObjects, startTime, frameRate, minDuration, 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 | |
| 26 print('Extracting speed from '+dbFilename) | 25 print('Extracting speed from '+dbFilename) |
| 27 aggFunctions, tmpheaders = utils.aggregationMethods(aggMethods, aggCentiles) | 26 aggFunctions, tmpheaders = utils.aggregationMethods(aggMethods, aggCentiles) |
| 28 objects = storage.loadTrajectoriesFromSqlite(dbFilename, 'object', nObjects) | 27 objects = storage.loadTrajectoriesFromSqlite(dbFilename, 'object', nObjects) |
| 29 for o in objects: | 28 for o in objects: |
| 30 if o.length() > minUserDuration: | 29 if o.length() > minDuration: |
| 31 row = [siteName, d, utils.framesToTime(o.getFirstInstant(), frameRate, t1), o.getUserType()] | 30 row = [siteName, d, utils.framesToTime(o.getFirstInstant(), frameRate, t1), o.getUserType()] |
| 32 tmp = o.getSpeeds() | 31 tmp = o.getSpeeds() |
| 33 for method,func in aggFunctions.items(): | 32 for method,func in aggFunctions.items(): |
| 34 aggSpeeds = frameRate*3.6*func(tmp) | 33 aggSpeeds = frameRate*3.6*func(tmp) |
| 35 if method == 'centile': | 34 if method == 'centile': |
