/* Given a pair of images and their keypoints, pick the first keypoint
   from one image and find its closest match in the second set of
   keypoints.  Then write the result to a file.
*/
void FindMatches(Image im1, Keypoint keys1, Image im2, Keypoint keys2)
{
    Keypoint k, match;
    Image result;
    int count = 0;

    /* Create a new image that joins the two images vertically. */
    result = CombineImagesVertically(im1, im2);

    /* Match the keys in list keys1 to their best matches in keys2.
    */
    for (k= keys1; k != NULL; k = k->next) {
      match = CheckForMatch(k, keys2);  

      /* Draw a line on the image from keys1 to match.  Note that we
	 must add row count of first image to row position in second so
	 that line ends at correct location in second image.
      */
      if (match != NULL) {
	count++;
	DrawLine(result, (int) k->row, (int) k->col,
		 (int) (match->row + im1->rows), (int) match->col);
      }
    }

    /* Write result image to standard output. */
    WritePGM(stdout, result);
    fprintf(stderr,"Found %d matches.\n", count);
}
示例#2
0
void compute_sift_matches(
	 keypointslist& keys1,  keypointslist& keys2,
	matchingslist& matchings,siftPar &par)
{
	float sqminratio = par.MatchRatio * par.MatchRatio;
		
	for (keypointslist::size_type i=0; i< keys1.size(); i++) {
        keypointslist::size_type imatch=0;
		float sqratio = CheckForMatch(keys1[i], keys2, imatch,par);
		if(sqratio < sqminratio)
			matchings.push_back( Match(keys1[i].x,keys1[i].y,
                                       keys2[imatch].x, keys2[imatch].y) );
	}
}
示例#3
0
/**
 * Returns the number of matches of keys between the two sets of keypoints.
 *
 * @return The number of matches between the two sets of keypoints.
 */
int FindMatches(Keypoint keys1, Keypoint keys2)
{
    Keypoint k, match;
    int count = 0;

    for (k= keys1; k != NULL; k = k->next) {
      match = CheckForMatch(k, keys2);  

      if (match != NULL) {
	count++;
      }
    }

    return count;
}