Can't use KalmanFilter in Android

asked 2014-02-10 06:28:59 -0600

TonySJH gravatar image

updated 2014-02-12 07:56:32 -0600

I'm writing an apps it can track an objcet 's center point , but when i define the KalmanFilter it show me this image description

and this is my code

public class KalmanFilter<boundingRect> extends Activity implements CvCameraViewListener2, OnTouchListener, Runnable, LocationListener{
private static final String TAG = "Kalman Filter";

private CameraBridgeViewBase mOpenCvCameraView;

private LocationManager myLocationManager;

private ColorBlobDetector    mDetector;

private KalmanFilter KF = new KalmanFilter(1, 2, 16, CvType.CV_64F);

/*
 * 
 * 
 * 
 * 
 * 
 */

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {        
    mRgba = inputFrame.rgba();
    mGray = inputFrame.gray();      

    /*
     * 
     * code for color detect
     * 
     */

    CenterX = mRgba.width() / 2;
    CenterY = mRgba.rows() / 2;
    int ObjectCenterX = (int)((mboundingRect.tl().x + mboundingRect.br().x) / 2);
    int ObjectCenterY = (int)((mboundingRect.tl().y + mboundingRect.br().y) / 2);

    Core.circle(mRgba, new Point(ObjectCenterX, ObjectCenterY), 5, ColorGreen, 2);

    try {                   
        Mat KalmanObjectPoint = new Mat(CvType.CV_32F);
        int[] KalmanPreObjectCenter = {ObjectCenterX, ObjectCenterY};
        KalmanObjectPoint.put(0, 0, KalmanPreObjectCenter[0]);
        KalmanObjectPoint.put(0, 1, KalmanPreObjectCenter[1]);
        KalmanObjectPoint = myKalmanFilter(KalmanObjectPoint);
    } catch (Exception e) {
        Log.e("In camera fram: ", e.toString());
    }


}

/***********************************Kalman filter***********************************************/
private Mat myKalmanFilter(Mat objectPoint){

    Mat correctMat = new Mat(CvType.CV_64F);
    Mat predictMat = new Mat(CvType.CV_64F);

    try {

        correctMat = objectPoint;

        KF.correct(correctMat);
        KF.predict(predictMat);


    } catch (Exception e) {
        Log.e("myKalmanFilter: ", e.toString());
    }

    return predictMat;
}

}

any help ?

edit retag flag offensive close merge delete