Added RootSIFT (issue #8): see "Feature2D/SIFT_rootSIFT" parameter

This commit is contained in:
matlabbe
2016-01-19 15:02:17 -05:00
parent 9525a55617
commit 138d004169
2 changed files with 21 additions and 0 deletions
+20
View File
@@ -460,6 +460,26 @@ void computeFeatures(
}
timeExtraction+=timeStep.restart();
}
if( Settings::getFeature2D_SIFT_rootSIFT() &&
Settings::currentDescriptorType() == "SIFT" &&
!descriptors.empty())
{
UINFO("Performing RootSIFT...");
// see http://www.pyimagesearch.com/2015/04/13/implementing-rootsift-in-python-and-opencv/
// apply the Hellinger kernel by first L1-normalizing and taking the
// square-root
for(int i=0; i<descriptors.rows; ++i)
{
descriptors.row(i) = descriptors.row(i) / cv::sum(descriptors.row(i))[0];
cv::sqrt(descriptors.row(i), descriptors.row(i));
// By taking the L1 norm, followed by the square-root, we have
// already L2 normalized the feature vector and further normalization
// is not needed.
//descs /= (np.linalg.norm(descs, axis=1, ord=2) + eps);
}
}
}