Mercurial Hosting > traffic-intelligence
diff scripts/test-compute-object-position-from-features.py @ 998:933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 27 May 2018 23:22:48 -0400 |
parents | 56cc8a1f7082 |
children |
line wrap: on
line diff
--- a/scripts/test-compute-object-position-from-features.py Fri May 25 18:15:18 2018 -0400 +++ b/scripts/test-compute-object-position-from-features.py Sun May 27 23:22:48 2018 -0400 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys @@ -70,7 +70,7 @@ # 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) + kalman=cv2.CreateKalman(6, 4) kalman.transition_matrix[0,2]=1 kalman.transition_matrix[0,4]=1./2 kalman.transition_matrix[1,3]=1 @@ -97,15 +97,15 @@ filteredPositions = moving.Trajectory() filteredVelocities = moving.Trajectory() measurement = cv.CreateMat(4,1,cv.CV_32FC1) - for i in xrange(positions.length()): - cv.KalmanPredict(kalman) # no control + for i in range(positions.length()): + kalman.predict() # no control p = positions[i] v = velocities[i] measurement[0,0] = p.x measurement[1,0] = p.y measurement[2,0] = v.x measurement[3,0] = v.y - cv.KalmanCorrect(kalman, measurement) + kalman.correct(measurement) filteredPositions.addPositionXY(kalman.state_post[0,0], kalman.state_post[1,0]) filteredVelocities.addPositionXY(kalman.state_post[2,0], kalman.state_post[3,0])