Kalman filter: some doubts

I have a few questions:

  • For the example specified in the openCV document:

    / * generate measurement * / cvMatMulAdd (kalman-> measure_matrix, state, measurement, measurement);

It is right? In the tutorial: An introduction to the Kalman filter from Welch and Bishop in Equation 1.2 says that measurement = H * state + noise measurement

It seems that both are not the same.

  • I tried to implement scanned ball tracking for one ball. I tried the following: (Please indicate if I am doing this incorrectly.)

To measure, I measure two things: a) xb) y the centroid of the ball.

I just mention lines that are different from the example given in the opencv documentation.

CvKalman* kalman = cvCreateKalman( 5, 2, 0 ); const float A[] = { 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1}; CvMat* state = cvCreateMat( 5, 1, CV_32FC1 ); CvMat* measurement = cvCreateMat( 2, 1, CV_32FC1 ); //initialize the state of kalman filter state->data.fl[0] = mean_c; state->data.fl[1] = mean_r; state->data.fl[2] = mean_c - prev_mean_c; state->data.fl[3] = mean_r - prev_mean_r; state->data.fl[4] = 9.81; 

after initialization, this is what fails

cvMatMulAdd (kalman-> transition_matrix, state, kalman-> process_noise_cov, state);

+4
source share
1 answer
  • On this line, they simply use measurement variables to store noise. See previous line:

    cvRandArr (& rng, measurement, CV_RAND_NORMAL, cvRealScalar (0), cvRealScalar (sqrt (kalman-> measurement_noise_cov-> data.fl [0])));

  • You must also resize the matrix H This should be 5 by 2 so that H*state + measurement noise can be calculated. You will probably get an error in the line

    memcpy (cvkalman-> measure_matrix-> data.fl, H, sizeof (H));

because in the original example cvkalman->measurement_matrix and H are allocated as 4 by 4 matrices, and you reduce the size of cvkalman->measurement_matrix only by 5 by 2 (4 * 4 is greater than 5 * 2)

+4
source

All Articles