difference between detect()/compute() and detectAndCompute() [closed]

asked 2016-04-21 06:32:51 -0500

anagno gravatar image

Hi everyone,

In the last couple of months, I am experimenting with the features extraction algorithms. I notice that there are two ways in computing the features and I was wondering what is the difference between:

std::vector<cv::KeyPoint> keypoint;
cv::Mat descriptors;

detector_->detect(frame_, keypoint);
descriptor_->compute(frame_, keypoint, descriptors);


std::vector<cv::KeyPoint> keypoint;
cv::Mat descriptors;

detector_->detectAndCompute(features_frame_, cv::noArray(),keypoint,descriptors)

when using the Feature2D class (http://docs.opencv.org/3.1.0/d0/d13/c...). Is there a reason to use the second call, instead of the first?

With kind regards


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-04 02:39:57.662040



The reason is fairly simple, namely the possibility to combine descriptors and detectors of keypoints as you wish.

  • detectAndCompute will only work if a technique provides both keypoint detector and keypoint descripter interface.
  • however the seperate interfaces allow you to use the detection of technique one while exploiting benefits of the descriptor of technique 2

It brings a tons of extra possibilities.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-22 06:37:57 -0500 )edit

One more question then. If I use the seperate interface (detect() / compute()) in a algortithm that provides both keypoint detector and descriptor (detectAndCompute()) will there be an overhead ???

anagno gravatar imageanagno ( 2016-04-22 07:59:34 -0500 )edit

Probably, but I am not sure if it will be a large influence!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-22 08:14:45 -0500 )edit

Thanks a lot for the info! Could you copy your first comment as answer so I could choose it as a correct answer?

anagno gravatar imageanagno ( 2016-04-22 08:24:19 -0500 )edit