This commit is contained in:
Maria Dimashova
2011-05-05 10:10:46 +00:00
parent 71d14386e4
commit 66c116ec6a
4 changed files with 91 additions and 41 deletions

View File

@@ -200,4 +200,25 @@ void KeyPointsFilter::runByKeypointSize( vector<KeyPoint>& keypoints, float minS
keypoints.end() );
}
class MaskPredicate
{
public:
MaskPredicate( const Mat& _mask ) : mask(_mask) {}
bool operator() (const KeyPoint& key_pt) const
{
return mask.at<uchar>( (int)(key_pt.pt.y + 0.5f), (int)(key_pt.pt.x + 0.5f) ) == 0;
}
private:
const Mat mask;
};
void KeyPointsFilter::runByPixelsMask( vector<KeyPoint>& keypoints, const Mat& mask )
{
if( mask.empty() )
return;
keypoints.erase(remove_if(keypoints.begin(), keypoints.end(), MaskPredicate(mask)), keypoints.end());
}
}