26 return (
int)((double)rand()*x/(double)RAND_MAX);
48 int aRemainingIterations =
_nIter;
53 unsigned int aMaxInliers = 0;
63 for(; aRemainingIterations > 0; aRemainingIterations--)
74 for(
int i=0; i<5; i++)
76 int n =
genint((
int)aMatches.size()-1);
77 aInliers.push_back(aMatches.at(n));
78 aMatches.erase(aMatches.begin()+n);
83 if (!aCurrentModel.
estimate(aInliers))
90 for (
size_t i = 0; i < aMatches.size(); ++i)
93 if (
calcError(&aCurrentModel, *aMatchesIter2) < aErrorDistSq)
95 aInliers.push_back(aMatchesIter2);
99 aOutliers.push_back(aMatchesIter2);
103 if (aInliers.size() > aMaxInliers)
107 for (
int i=0; i<3; ++i)
108 for(
int j=0; j<3; ++j)
120 aMaxInliers = (
unsigned int)aInliers.size();
121 aBestInliers = aInliers;
122 aBestOutliers = aOutliers;
128 if (aOutliers.empty())
137 ioMatches = aBestInliers;
138 ioRemovedMatches = aBestOutliers;
std::vector< PointMatchPtr > PointMatchVector_t
void initMatchesNormalization(PointMatchVector_t &iMatches)
void transformPoint(double iX, double iY, double &oX, double &oY)
void transform(double iX, double iY, double &oX, double &oY)
void filter(std::vector< PointMatchPtr > &ioMatches, std::vector< PointMatchPtr > &ioRemovedMatches)
double calcError(Homography *aH, PointMatch &aM)
bool estimate(PointMatchVector_t &iMatches)
std::shared_ptr< PointMatch > PointMatchPtr