예제 #1
0
void compute_sift_matches(
	 keypointslist& keys1,  keypointslist& keys2,
	matchingslist& matchings,siftPar &par)
{
	int	imatch=0;
	float	sqminratio = par.MatchRatio * par.MatchRatio,
		sqratio;
		
	// write the keypoint descriptors in char
	keypointslist_short keys1_short(keys1.size());
	for (int i=0; i< (int) keys1.size(); i++)
	{
		keys1_short[i].x = keys1[i].x;
		keys1_short[i].y = keys1[i].y;
		keys1_short[i].scale = keys1[i].scale;
		keys1_short[i].angle = keys1[i].angle;
		
		for (int k=0; k < VecLength; k++)
		{
			keys1_short[i].vec[k] = (unsigned short) (keys1[i].vec[k]);
		}

	}
	
	keypointslist_short keys2_short(keys2.size());
	for (int i=0; i< (int) keys2.size(); i++)
	{
		keys2_short[i].x = keys2[i].x;
		keys2_short[i].y = keys2[i].y;
		keys2_short[i].scale = keys2[i].scale;
		keys2_short[i].angle = keys2[i].angle;
		
		for (int k=0; k < VecLength; k++)
		{
			keys2_short[i].vec[k] = (unsigned short) (keys2[i].vec[k]);
		}
		
	}
	
	for (int i=0; i< (int) keys1.size(); i++) {

	//	sqratio = CheckForMatch(keys1[i], keys2, imatch,par);
		
		sqratio = CheckForMatch_short(keys1_short[i], keys2_short, imatch,par);

		if (sqratio< sqminratio){
			//std::cout << "ok:" << sqratio << " , " << std::endl;
			matchings.push_back( matching(keys1[i],keys2[imatch] ));
		}else{
			//std::cout << "ng:" << sqratio << " , " << std::endl;
		}
			//		 matchings.push_back( matching_char(keys1_char[i],keys2_char[imatch] ));
	}
}
예제 #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
/* This searches through the keypoints in klist for the two closest
   matches to key.  It returns the ratio of the distance to key of the
   closest and next to closest keypoints in klist, while bestindex is the index
   of the closest keypoint.
*/
float CheckForMatch(
keypoint& key, keypointslist& klist, keypointslist::size_type& min,siftPar &par)
{
	float	dsq, distsq1, distsq2;
	distsq1 = distsq2 = 1000000000000.0f;

	for (keypointslist::size_type j=0; j< klist.size(); j++){
	
		dsq = DistSquared(key, klist[j], distsq2,par);
		
		if (dsq < distsq1) {
			distsq2 = distsq1;
			distsq1 = dsq;
			min = j;
		} else if (dsq < distsq2)
			distsq2 = dsq;
	}

	return distsq1/distsq2 ;
}
예제 #4
0
/* This searches through the keypoints in klist for the two closest
   matches to key.  It returns the ratio of the distance to key of the
   closest and next to closest keypoints in klist, while bestindex is the index
   of the closest keypoint.
*/
float CheckForMatch(
	 keypoint& key, keypointslist& klist, int& min,siftPar &par)
{	
	int	nexttomin = -1;
	float	dsq, distsq1, distsq2;
	distsq1 = distsq2 = 1000000000000.0f;

	for (int j=0; j< (int) klist.size(); j++){
	
		dsq = DistSquared(key, klist[j], distsq2,par);
		
		if (dsq < distsq1) {
			distsq2 = distsq1;
			distsq1 = dsq;
			nexttomin = min;
			min = j;
		} else if (dsq < distsq2) {
			distsq2 = dsq;
			nexttomin = j;
		}
	}

	return distsq1/distsq2 ;
}