I am working on object recognition in android. So far i am able to detect/recognise objects at a frame rate of 5-8 fps. Now,i want to track the detected object in subsequent frames.
short summary of what i have done so far.
- capture and store the object of interest in external directory of the phone as an image.
- Detect and extract the feature points(used ORB feature detector and descriptor).
- Perform matching and draw rectangular box around the detected object(Homography).
example of the object which is detected.
Now, after performing homography, I intend to track the object in subsequent frames. Which are the possible algorithms which can do this(Is this method of tracking after detection possible)?.I have gone through particle filter and kalman filter based tracking, but unable to understand which parameters need to be passed to instantiate tracking after homography. Any reference to tracking algorithms,documents, example codes in openCV would be helpful.
EDIT
for(int i_gm=0; i_gm<goodmatches.size(); i_gm++)
{
scene.push_back(v1[goodmatches[i_gm].trainIdx].pt);
objnew.x+=scene[i_gm].x;
objnew.y+=scene[i_gm].y;
}
// calculation of centroid of the object.
objnew.x/=scene.size();
objnew.y/=scene.size();
// Kalman predict and correct.
KfMeasurement.setTo(Scalar(0));
Kf.statePre.at<float>(0)=objnew.x;
Kf.statePre.at<float>(1)=objnew.y;
Kf.statePre.at<float>(2)=0;
Kf.statePre.at<float>(3)=0;
Kf.transitionMatrix=(Mat_<float>(4,4)<< 1,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1);
setIdentity(Kf.measurementMatrix);
setIdentity(Kf.processNoiseCov,Scalar::all(1e-5));
setIdentity(Kf.measurementNoiseCov,Scalar::all(1e-1));
setIdentity(Kf.errorCovPost,Scalar::all(.1));
Mat prediction = Kf.predict();
Point predictPt(prediction.at<float>(0),prediction.at<float>(1));
KfMeasurement(0)=objnew.x;
KfMeasurement(1)=objnew.y;
Point measPt(KfMeasurement(0),KfMeasurement(1));
Mat estimated=Kf.correct(KfMeasurement);
Point statept(estimated.at<float>(0),estimated.at<float>(1));
circle( kalRgba,statept,50, Scalar(255,255,255), 3 );
circle(kalRgba, measPt, 10,Scalar(10,10,255), 3 );
circle( kalRgba,predictPt,10, Scalar(100,255,0), 3 );