Mercurial Hosting > traffic-intelligence
changeset 106:ce4cb46b3603
added kalman filtering and rearranged functions
author | Nicolas Saunier <nico@confins.net> |
---|---|
date | Thu, 14 Jul 2011 20:05:01 -0400 |
parents | 9844c69d8fa2 |
children | 916678481896 |
files | python/compute-object-from-features.py |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/python/compute-object-from-features.py Thu Jul 14 19:48:30 2011 -0400 +++ b/python/compute-object-from-features.py Thu Jul 14 20:05:01 2011 -0400 @@ -32,7 +32,9 @@ invh = cvutils.invertHomography(h) -def computeObject(features, homography, timeInterval = None): +def computeGroundTrajectory(features, homography, timeInterval = None): + '''Computes a trajectory for the set of features as the closes point to the ground + using the homography in image space''' if not timeInterval: raise Exception('not implemented') # compute from the features @@ -50,7 +52,7 @@ return newTraj -# TODO version median +# TODO version median: conversion to large matrix will not work, have to do it frame by frame def kalmanFilter(positions, velocities, processNoiseCov, measurementNoiseCov): kalman=cv.CreateKalman(6, 4) @@ -94,10 +96,12 @@ return (filteredPositions, filteredVelocities) -(filteredPositions, filteredVelocities) = kalmanFilter(newTraj, obj.getVelocities(), 1e-5, 1e-1) +lowTrajectory = computeGroundTrajectory([features[i] for i in obj.featureNumbers], invh, obj.getTimeInterval()) +(filteredPositions, filteredVelocities) = kalmanFilter(lowTrajectory, obj.getVelocities(), 0.1, 0.1) plt.clf() -obj.draw('rx') +obj.draw('rx-') for fnum in obj.featureNumbers: features[fnum].draw() -newTraj.draw('bx') +lowTrajectory.draw('bx-') +filteredPositions.draw('gx-') plt.axis('equal')