Path: blob/master/experiments/image_tracker.py
1700 views
# -*- coding: utf-8 -*-1"""2Created on Sat May 24 14:42:55 201434@author: rlabbe5"""67from KalmanFilter import KalmanFilter8import numpy as np9import matplotlib.pyplot as plt10import numpy.random as random1112f = KalmanFilter (dim=4)1314dt = 115f.F = np.mat ([[1, dt, 0, 0],16[0, 1, 0, 0],17[0, 0, 1, dt],18[0, 0, 0, 1]])1920f.H = np.mat ([[1, 0, 0, 0],21[0, 0, 1, 0]])22232425f.Q *= 4.26f.R = np.mat([[50,0],27[0, 50]])2829f.x = np.mat([0,0,0,0]).T30f.P *= 100.313233xs = []34ys = []35count = 20036for i in range(count):37z = np.mat([[i+random.randn()*1],[i+random.randn()*1]])38f.predict ()39f.update (z)40xs.append (f.x[0,0])41ys.append (f.x[2,0])424344plt.plot (xs, ys)45plt.show()46474849