Right, I solve the key tracking using cvMatchTemplate
//Copy selected portion of the image to the subject image;
subjectFrame.x = x; // desired track point X
subjectFrame.y = y; // desired track point Y
subjectImg.allocate(subjectFrame.width, subjectFrame.height);
grayImage.setROI(subjectFrame);
subjectImg = grayImage;
grayImage.resetROI();
subjectIsDefined = true;
.
/* motion track */
colorImg.setFromPixels(videoPlayer.getPixels());
grayImage = colorImg;
if(subjectIsDefined)
{
IplImage * result = cvCreateImage(cvSize(desiredWidth - subjectImg.width + 1, desiredHeight - subjectImg.height + 1), 32, 1);
cvMatchTemplate(grayImage.getCvImage(), subjectImg.getCvImage(), result, CV_TM_SQDIFF);
double minVal, maxVal;
CvPoint minLoc, maxLoc;
cvMinMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, 0);
subjectLocation.x = minLoc.x;
subjectLocation.y = minLoc.y;
cvReleaseImage( & result );
}
Thanks