Commit 36477fde authored by Maksim Shabunin's avatar Maksim Shabunin

Merge pull request #6344 from anatolix:kalmanpyfix

parents ee9f8890 1740218e
#!/usr/bin/python #!/usr/bin/env python
""" """
Tracking of rotating point. Tracking of rotating point.
Rotation speed is constant. Rotation speed is constant.
...@@ -19,7 +19,7 @@ if PY3: ...@@ -19,7 +19,7 @@ if PY3:
long = int long = int
import cv2 import cv2
from math import cos, sin from math import cos, sin, sqrt
import numpy as np import numpy as np
if __name__ == "__main__": if __name__ == "__main__":
...@@ -81,16 +81,16 @@ if __name__ == "__main__": ...@@ -81,16 +81,16 @@ if __name__ == "__main__":
kalman.correct(measurement) kalman.correct(measurement)
process_noise = kalman.processNoiseCov * np.random.randn(2, 1) process_noise = sqrt(kalman.processNoiseCov[0,0]) * np.random.randn(2, 1)
state = np.dot(kalman.transitionMatrix, state) + process_noise state = np.dot(kalman.transitionMatrix, state) + process_noise
cv2.imshow("Kalman", img) cv2.imshow("Kalman", img)
code = cv2.waitKey(100) % 0x100 code = cv2.waitKey(100)
if code != -1: if code != -1:
break break
if code in [27, ord('q'), ord('Q')]: if (code % 0x100) in [27, ord('q'), ord('Q')]:
break break
cv2.destroyWindow("Kalman") cv2.destroyWindow("Kalman")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment