fixed PyramidAdaptedFeatureDetector (when mask is not empty) (#1206)
This commit is contained in:
parent
c380dd579b
commit
370130e464
@ -602,11 +602,22 @@ bool PyramidAdaptedFeatureDetector::empty() const
|
||||
void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||
{
|
||||
Mat src = image;
|
||||
Mat src_mask = mask;
|
||||
|
||||
Mat dilated_mask;
|
||||
if( !mask.empty() )
|
||||
{
|
||||
dilate( mask, dilated_mask, Mat() );
|
||||
Mat mask255( mask.size(), CV_8UC1, Scalar(0) );
|
||||
mask255.setTo( Scalar(255), dilated_mask != 0 );
|
||||
dilated_mask = mask255;
|
||||
}
|
||||
|
||||
for( int l = 0, multiplier = 1; l <= maxLevel; ++l, multiplier *= 2 )
|
||||
{
|
||||
// Detect on current level of the pyramid
|
||||
vector<KeyPoint> new_pts;
|
||||
detector->detect( src, new_pts, mask );
|
||||
detector->detect( src, new_pts, src_mask );
|
||||
for( vector<KeyPoint>::iterator it = new_pts.begin(), end = new_pts.end(); it != end; ++it)
|
||||
{
|
||||
it->pt.x *= multiplier;
|
||||
@ -620,10 +631,16 @@ void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoin
|
||||
if( l < maxLevel )
|
||||
{
|
||||
Mat dst;
|
||||
pyrDown(src, dst);
|
||||
pyrDown( src, dst );
|
||||
src = dst;
|
||||
|
||||
if( !mask.empty() )
|
||||
resize( dilated_mask, src_mask, src.size(), 0, 0, CV_INTER_AREA );
|
||||
}
|
||||
}
|
||||
|
||||
if( !mask.empty() )
|
||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user