Skip to content

Instantly share code, notes, and snippets.

@JefferyRPrice
Last active August 31, 2015 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JefferyRPrice/8a9550e3a3d85969af21 to your computer and use it in GitHub Desktop.
Save JefferyRPrice/8a9550e3a3d85969af21 to your computer and use it in GitHub Desktop.
AGAST detector is ~30x slower than FAST detector
// Output (DETECTOR, num detected points, total milliseconds)
// AGAST, 3715, 31672
// FAST, 3735, 1025
int main(int argc, char *argv[])
{
cv::Ptr<cv::AgastFeatureDetector> agast =
cv::AgastFeatureDetector::create(10, true, cv::AgastFeatureDetector::OAST_9_16);
cv::Ptr<cv::FastFeatureDetector> fast =
cv::FastFeatureDetector::create(10, true, cv::FastFeatureDetector::TYPE_9_16);
cv::Mat img = cv::imread("example.jpg", cv::IMREAD_GRAYSCALE); // 512x512
size_t NumLoops = 500;
double startTicks, elapsedTicks, elapsedMilliseconds;
size_t agastPoints = 0;
startTicks = (double) cv::getTickCount();
for(size_t nn = 0; nn < NumLoops; nn++) {
std::vector<cv::KeyPoint> keypoints;
agast->detect(img, keypoints);
agastPoints += keypoints.size();
}
elapsedTicks = (double) cv::getTickCount() - startTicks;
elapsedMilliseconds = 1.0e3 / cv::getTickFrequency() * elapsedTicks;
std::cout << "AGAST, " << (int)((double)agastPoints/NumLoops) << ", " << (int)elapsedMilliseconds << std::endl;
size_t fastPoints = 0;
startTicks = (double) cv::getTickCount();
for(size_t nn = 0; nn < NumLoops; nn++) {
std::vector<cv::KeyPoint> keypoints;
fast->detect(img, keypoints);
fastPoints += keypoints.size();
}
elapsedTicks = (double) cv::getTickCount() - startTicks;
elapsedMilliseconds = 1.0e3 / cv::getTickFrequency() * elapsedTicks;
std::cout << "FAST, " << (int)((double)fastPoints/NumLoops) << ", " << (int)elapsedMilliseconds << std::endl;
}
@JefferyRPrice
Copy link
Author

(Using OpenCV 3.0)

Illustrates that for a 500 loop run on an example image, the AGAST detector took a total of 31.7 seconds while the FAST detector took 1.03 seconds. Number of points detected by each is approximately the same (3715 for AGAST and 3735 for FAST).

Submitted as Issue #5278.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment