Mercurial Hosting > traffic-intelligence
changeset 595:17b02c8054d0
added tests and corrected one bug
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 07 Dec 2014 22:59:47 -0500 |
parents | 9e39cd95e017 |
children | 04a8304e13f0 aee4cbac9e0e |
files | python/moving.py python/tests/moving.txt scripts/compute-clearmot.py |
diffstat | 3 files changed, 41 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Sun Dec 07 01:32:36 2014 -0500 +++ b/python/moving.py Sun Dec 07 22:59:47 2014 -0500 @@ -1315,7 +1315,7 @@ else: return matchingDistance + 1 -def computeClearMOT(objects, annotations, matchingDistance, firstInstant, lastInstant, debug = False): +def computeClearMOT(annotations, objects, matchingDistance, firstInstant, lastInstant, debug = False): '''Computes the CLEAR MOT metrics Reference: @@ -1368,10 +1368,7 @@ nTOs = len(matchedTOs)+len(unmatchedTOs) if len(unmatchedTOs) > 0: for a in unmatchedGTs: - aCosts = [a.matches(o, t, matchingDistance) for o in unmatchedTOs] - if min(aCosts) < matchingDistance: - costs.append(aCosts) - # print costs + costs.append([a.matches(o, t, matchingDistance) for o in unmatchedTOs]) if len(costs) > 0: newMatches = munk.compute(costs) for k,v in newMatches: @@ -1408,7 +1405,11 @@ motp = dist/ct else: motp = None - return motp, 1.-float(mt+fpt+mme)/gt, mt, mme, fpt, gt + if gt > 0: + mota = 1.-float(mt+fpt+mme)/gt + else: + mota = None + return motp, mota, mt, mme, fpt, gt def plotRoadUsers(objects, colors):
--- a/python/tests/moving.txt Sun Dec 07 01:32:36 2014 -0500 +++ b/python/tests/moving.txt Sun Dec 07 22:59:47 2014 -0500 @@ -160,3 +160,36 @@ >>> o1.classifyUserTypeSpeedMotorized(1.5, np.median) >>> userTypeNames[o1.getUserType()] 'pedestrian' + +>>> o1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) +>>> gt1 = BBAnnotation(1, TimeInterval(0,10), MovingObject.generate(Point(0.2,0.6), Point(1.,0.), TimeInterval(0,10)), MovingObject.generate(Point(-0.2,-0.4), Point(1.,0.), TimeInterval(0,10))) +>>> gt1.computeCentroidTrajectory() +>>> computeClearMOT([gt1], [], 0.2, 0, 10) +(None, 0.0, 11, 0, 0, 11) +>>> computeClearMOT([], [o1], 0.2, 0, 10) +(None, None, 0, 0, 11, 0) +>>> computeClearMOT([gt1], [o1], 0.2, 0, 10) # doctest:+ELLIPSIS +(0.0999..., 1.0, 0, 0, 0, 11) +>>> computeClearMOT([gt1], [o1], 0.05, 0, 10) +(None, -1.0, 11, 0, 11, 11) + +>>> o1 = MovingObject(1, TimeInterval(0,3), positions = Trajectory([range(4), [0.1, 0.1, 1.1, 1.1]])) +>>> o2 = MovingObject(2, TimeInterval(0,3), positions = Trajectory([range(4), [0.9, 0.9, -0.1, -0.1]])) +>>> gt1 = BBAnnotation(1, TimeInterval(0,3), MovingObject(positions = Trajectory([range(4), [0.]*4])), MovingObject(positions = Trajectory([range(4), [0.]*4]))) +>>> gt1.computeCentroidTrajectory() +>>> gt2 = BBAnnotation(2, TimeInterval(0,3), MovingObject(positions = Trajectory([range(4), [1.]*4])), MovingObject(positions = Trajectory([range(4), [1.]*4]))) +>>> gt2.computeCentroidTrajectory() +>>> computeClearMOT([gt1, gt2], [o1, o2], 0.2, 0, 3) # doctest:+ELLIPSIS +(0.1..., 0.75, 0, 2, 0, 8) +>>> computeClearMOT([gt2, gt1], [o2, o1], 0.2, 0, 3) # doctest:+ELLIPSIS +(0.1..., 0.75, 0, 2, 0, 8) +>>> computeClearMOT([gt1], [o1, o2], 0.2, 0, 3) +(0.1, -0.25, 0, 1, 4, 4) +>>> computeClearMOT([gt1], [o2, o1], 0.2, 0, 3) # symmetry +(0.1, -0.25, 0, 1, 4, 4) +>>> computeClearMOT([gt1, gt2], [o1], 0.2, 0, 3) # doctest:+ELLIPSIS +(0.100..., 0.375, 4, 1, 0, 8) +>>> computeClearMOT([gt2, gt1], [o1], 0.2, 0, 3) # doctest:+ELLIPSIS +(0.100..., 0.375, 4, 1, 0, 8) +>>> computeClearMOT([gt1, gt2], [o1, o2], 0.08, 0, 3) +(None, -1.0, 8, 0, 8, 8)
--- a/scripts/compute-clearmot.py Sun Dec 07 01:32:36 2014 -0500 +++ b/scripts/compute-clearmot.py Sun Dec 07 22:59:47 2014 -0500 @@ -30,7 +30,7 @@ for a in annotations: a.computeCentroidTrajectory(homography) -motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(objects, annotations, args.matchingDistance, args.firstInstant, args.lastInstant) +motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant) print 'MOTP: {}'.format(motp) print 'MOTA: {}'.format(mota)