How to sort opencv KeyPoints according to the response?
c++, opencv
Solution
Looking at the documentation, and guessing you are trying to do something like this,
Here is how KeyPoint is implemented in OpenCV.
So from what I understand, what you want to use is the response element:
float response; // the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
So this is definitely what I would be going to in your case. Create a function that sorts your vector by response :)
Hope this helps
EDIT:
Trying to take advantage of Adrian's advice (This is my first cpp code though, so expect to have some corrections to perform)
// list::sort
#include <list>
#include <cctype>
using namespace std;
// response comparison, for list sorting
bool compare_response(KeyPoints first, KeyPoints second)
{
if (first.response < second.response) return true;
else return false;
}
int main ()
{
list<KeyPoints> mylist;
list<KeyPoints>::iterator it;
// opencv code that fills up my list
mylist.sort(compare_response);
return 0;
}
Problem
I've some OpenCV KeyPoints, and they are stored as `vector<KeyPoint>` or `list<KeyPoint>`. How to sort them according to the response of the KeyPoints to obtain the best n keypoints? Regards.