Mercurial Hosting > traffic-intelligence
changeset 664:455f9b93819c
added capability to set a videofilename to movingobject and interaction, renames interactiontype to collision in interaction
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 20 May 2015 12:04:22 +0200 |
parents | 65a867942eee |
children | 15e244d2a1b5 |
files | python/events.py python/moving.py python/storage.py |
diffstat | 3 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/python/events.py Tue May 19 16:58:26 2015 +0200 +++ b/python/events.py Wed May 20 12:04:22 2015 +0200 @@ -9,6 +9,7 @@ import itertools import moving, prediction, indicators, utils, cvutils +from storage import VideoFilenameAddable __metaclass__ = type def findRoute(prototypes,objects,i,j,noiseEntryNums,noiseExitNums,minSimilarity= 0.3, spatialThreshold=1.0, delta=180): @@ -41,7 +42,7 @@ route= findRoute(prototypes,objects,route,obj.getNum(),noiseEntryNums,noiseExitNums) return route -class Interaction(moving.STObject): +class Interaction(moving.STObject, VideoFilenameAddable): '''Class for an interaction between two road users or a road user and an obstacle @@ -231,12 +232,15 @@ # TODO add crossing zone self.pet = moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold) - def addVideoFilename(self,videoFilename): - self.videoFilename = videoFilename + def setCollision(self, collision): + '''indicates if it is a collision: argument should be boolean''' + self.collision = collision - def addInteractionType(self,interactionType): - ''' interaction types: conflict or collision if they are known''' - self.interactionType = interactionType + def isCollision(self): + if hasattr(self, 'collision'): + return self.collision + else: + return None def getCrossingZones(self, predictionMethodName): if self.crossingZones is not None:
--- a/python/moving.py Tue May 19 16:58:26 2015 +0200 +++ b/python/moving.py Wed May 20 12:04:22 2015 +0200 @@ -1,8 +1,8 @@ #! /usr/bin/env python '''Libraries for moving objects, trajectories...''' -import utils -import cvutils +import utils, cvutils +from storage import VideoFilenameAddable from math import sqrt from numpy import median @@ -974,7 +974,7 @@ userType2Num = utils.inverseEnumeration(userTypeNames) -class MovingObject(STObject): +class MovingObject(STObject, VideoFilenameAddable): '''Class for moving objects: a spatio-temporal object with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see userTypeNames)
--- a/python/storage.py Tue May 19 16:58:26 2015 +0200 +++ b/python/storage.py Wed May 20 12:04:22 2015 +0200 @@ -867,7 +867,14 @@ # Utils to read .ini type text files for configuration, meta data... ######################### -class ProcessParameters: +class VideoFilenameAddable: + 'Base class with the capability to attach a video filename' + + def setVideoFilename(self, videoFilename): + self.videoFilename = videoFilename + + +class ProcessParameters(VideoFilenameAddable): '''Class for all parameters controlling data processing: input, method parameters, etc. for tracking, classification and safety @@ -952,7 +959,6 @@ return configDict - if __name__ == "__main__": import doctest import unittest