问题
I am doing a project with openCV, where I matched two images with the SIFT keypoints and got good match from the same using K nearest neighbor search. where k=2.
Now I want to get the co-ordinate value of the SIFT keypoints which has good match in the image2 and also the co-ordinate value for the corresponding keypoints in Image2. Can any body help me with this. thanks.
I find out the solution...It was very easy...silly me...I just converted the keypoints into CvPoints and from that I can easily get the co-ordinate values....
回答1:
All.. I have solved the problem...at frist i converted the good matched keypoints into Cvpoints and then got the co-ordinate from the Cvpoints..the code for the same is as below-
for( i =0; i <good_matches.size(); i++ )
{
// the keypoints from the good matches only
points1.push_back( keypoints1[ good_matches[i].queryIdx ].pt );
points2.push_back( keypoints2[ good_matches[i].trainIdx ].pt );
printf("xco-ordinate of good mathched keypoints in image1 %d\n\n",points1[i].x);
printf("y co-ordinate for image 1 %d \n\n",points1[i].y);
printf("x co-ordinate for image2 %d \n\n",points2[i].x);
printf("y co-ordinate for image2 %d\n\n",points2[i].y);
}
回答2:
You can get the neighbor vectors using CvKNearest::find_nearest(...). I believe you're looking for the parameter neighbors.
References:
http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html?highlight=cvknearest#cvknearest-find-nearest
Older documentation but w/code example:
http://opencv.willowgarage.com/documentation/cpp/k_nearest_neighbors.html
来源:https://stackoverflow.com/questions/10345832/co-ordinate-of-the-matched-sift-keypoints