How do I smooth feature trajectories of lkdemo

asked 2015-11-30 14:30:39 -0600

I've to smooth feature trajectories of Lucas Kanade and for that purpose, its possible to apply low pass filter to x and y coordinates of the tracked feature points in lkdemo. I got thee understanding of applying low pass filter to image in opencv but I can't get it in lkdemo. What I've tried is completely wrong in my opinion. Please guide me so that I can solve m issue. My trial is given as:

void conv2(vector<vector<Point2f>> src, int kernel_size)
{
    vector<vector<Point2f>> dst;
    Mat kernel;
    kernel = Mat::ones(kernel_size, kernel_size, CV_32F) / (float)(kernel_size*kernel_size);

    /// Apply filter
    filter2D(src, dst, -1, kernel, Point(-1, -1), 0, BORDER_DEFAULT);
    //namedWindow("filter2D Demo", CV_WINDOW_AUTOSIZE); imshow("filter2D Demo", dst);
}

and then at the end of main function of lkdemo,

conv2(pointsFrame, 3);

waitKey(0);

return 0;
}
edit retag flag offensive close merge delete

Comments

Do you want to filter off line or on line? off line you can use convolution an on line you can use IIR. It's not 2D signal but 1D signal with complex number

LBerger gravatar imageLBerger ( 2015-11-30 14:56:15 -0600 )edit

Sorry! that is feature locations...I want to smooth the feature locations so that I can compare (later) the content' position like where it is supposed to be (smooth locations) and where it is (lkdemo output)...

Ayesha Siddique gravatar imageAyesha Siddique ( 2015-12-01 00:44:45 -0600 )edit
1

Feature location mean P(x,y) (?). In that case you can use convolution but you can use kalman filter like in this post. It will depend on your application...

LBerger gravatar imageLBerger ( 2015-12-01 01:29:16 -0600 )edit

@LBerger can you please help me here link text

Ayesha Siddique gravatar imageAyesha Siddique ( 2016-02-02 01:11:12 -0600 )edit