Mercurial Hosting > traffic-intelligence
view python/processing.py @ 1020:9fb82fe0156f
added quiet tracking mode
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 05 Jun 2018 14:33:31 -0400 |
parents | 933670761a57 |
children |
line wrap: on
line source
#! /usr/bin/env python '''Algorithms to process trajectories and moving objects''' import moving import numpy as np 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 range(int(o.length()-1)) if inPolygon[i]] speeds[o.num] = np.mean(objspeeds) # km/h else: objectsNotInZone.append(o) return speeds, objectsNotInZone