Mercurial > hg > nsaunier > traffic-intelligence
view python/processing.py @ 554:7d051afcb22d
added back simple makefile to install the feature-based tracking executable and the scripts in /usr/local/bin so that they are accessible without typing the path to the source folder
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 11 Jul 2014 16:25:57 -0400 |
| parents | 583a2c4622f9 |
| children | 15e244d2a1b5 |
line wrap: on
line source
#! /usr/bin/env python '''Algorithms to process trajectories and moving objects''' __metaclass__ = type import numpy as np import moving def extractSpeeds(objects, zone): speeds = {} objectsNotInZone = [] import matplotlib.nxutils as nx for o in objects: inPolygon = nx.points_inside_poly(o.getPositions().asArray().T, zone.T) if inPolygon.any(): objspeeds = [o.getVelocityAt(i).norm2() for i in xrange(int(o.length()-1)) if inPolygon[i]] speeds[o.num] = np.mean(objspeeds) # km/h else: objectsNotInZone.append(o) return speeds.values(), speeds, objectsNotInZone
