Reputation: 6079
I am using OpenCV 3.0 beta, I want to use Kalman Filter, but I cannot find any example of the Kalman Filter implementation in Java OpenCV. I have tried the example code in C++ and Python, but I cannot completely translate this code to Java.
Upvotes: 0
Views: 2453
Reputation: 11201
The thing you might miss when porting OpenCV C++/Python Kalman filter sample to Java is how to set transition/control or measurement matrices. Unfortunately Opencv java doc(1) for Kalman filter doesn't mention those methods. Hope this code sample(2) from github helps. You might need OpenCV 3.0 though.
KalmanFilter kalman = new KalmanFilter(4, 2, 0, CvType.CV_32F);
Mat transitionMatrix = new Mat(4, 4, CvType.CV_32F, new Scalar(0));
float[] tM = { 1, 0, 1, 0,
0, 1, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1 } ;
transitionMatrix.put(0,0,tM);
kalman.set_transitionMatrix(transitionMatrix);
Upvotes: 3