Mercurial Hosting > traffic-intelligence
changeset 653:107f1ad02b69
compilation with C++11 and test function for movingobject distance
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 07 May 2015 13:25:31 +0200 |
parents | 3b13ec964476 |
children | 045d05cef9d0 |
files | c/Makefile python/moving.py |
diffstat | 2 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Makefile Fri Apr 24 17:02:47 2015 +0200 +++ b/c/Makefile Thu May 07 13:25:31 2015 +0200 @@ -13,7 +13,7 @@ LDFLAGS += -lboost_program_options -lboost_filesystem -lboost_system #LDFLAGS += -lfltk -CFLAGS = -Wall -W -Wextra +CFLAGS = -Wall -W -Wextra -std=c++11 UNAME = $(shell uname) ifneq ($(OPENCV), 0)
--- a/python/moving.py Fri Apr 24 17:02:47 2015 +0200 +++ b/python/moving.py Thu May 07 13:25:31 2015 +0200 @@ -1155,7 +1155,27 @@ plot(list(self.getTimeInterval()), speeds) @staticmethod + def minMaxDistance(obj1, obj2): + '''Computes the min max distance used for feature grouping''' + commonTimeInterval = obj1.commonTimeInterval(obj2) + if not commonTimeInterval.empty(): + minDistance = (obj1.getPositionAtInstant(commonTimeInterval.first)-obj2.getPositionAtInstant(commonTimeInterval.first)).norm2() + maxDistance = minDistance + for t in list(commonTimeInterval)[1:]: + d = (obj1.getPositionAtInstant(t)-obj2.getPositionAtInstant(t)).norm2() + if d<minDistance: + minDistance = d + elif d>maxDistance: + maxDistance = d + return int(commonTimeInterval.length()), minDistance, maxDistance + else: + return int(commonTimeInterval.length()), None, None + + @staticmethod def distances(obj1, obj2, instant1, _instant2 = None): + '''Returns the distances between all features of the 2 objects + at the same instant instant1 + or at instant1 and instant2''' from scipy.spatial.distance import cdist if _instant2 is None: instant2 = instant1