0

Similar to this post and this post, I want to convert detected keypoints to elliptic keypoints by modifying this sample SURF detection and matching code from opencv library.

However, I have little knowledge on c++ syntax and am only familiar with matlab. Previous posts seem to point to using the following code from evaluation.cpp of opencv library to convert them:

void EllipticKeyPoint::convert( const std::vector<KeyPoint>& src, std::vector<EllipticKeyPoint>& dst )
{
    if( !src.empty() )
    {
        dst.resize(src.size());
        for( size_t i = 0; i < src.size(); i++ )
        {
            float rad = src[i].size/2;
            CV_Assert( rad );
            float fac = 1.f/(rad*rad);
            dst[i] = EllipticKeyPoint( src[i].pt, Scalar(fac, 0, fac) );
        }
    }
} 

The Keypoints seem to be generated after line 202 of sample code. So I tried the following to convert them to elliptic keypoints by adding:

  • cv::EllipticKeyPoint::convert(keypoints1, keypoints1); after line 202 and
  • using namespace cv::xfeatures2d::EllipticKeyPoint at the beginning of the code

but both showed errors saying:

  • name followed by '::' must be a class or namespace name and
  • namespace "cv::xfeatures2d" has no member "EllipticKeyPoint" respectively

Which class/namespace/member should I use? How do I write the code properly so that I can use this function to convert keypoints to elliptic keypoints?

Community
  • 1
  • 1
SK90
  • 69
  • 9

1 Answers1

1

Welk... you should show us your exact code if you want sensible answers, but...

If I'm not wrong, the message "name followed by '::' must be a class or namespace name" is misleading: can be a static method name too, that is your intention.

The problem, I suppose, is another.

There are defined two convert() static methods in EllipticKeyPoint: the first one convert vectors of KeyPoint in vectors of EllipticKeyPoint; the second one convert vectors of EllipticKeyPoint in vectors of KeyPoint.

But when you call

cv::EllipticKeyPoint::convert(keypoints1, keypoints1);

you try to convert keypoints1 to itself; so (vectors of) KeyPoint to KeyPoint or EllipticKeyPoint to EllipticKeyPoint.

And you lack this type of converter.

Your intention was the following ?

cv::EllipticKeyPoint::convert( _keypoints1 , keypoints1 );

In calculateRepeatability() I see

EllipticKeyPoint::convert( _keypoints1, keypoints1 );
EllipticKeyPoint::convert( _keypoints2, keypoints2 );

so be careful with underscores (_).

--- EDIT 2016.06.11 ---

If your intention is convert the vectors of KeyPoint in vectors of EllipticKeyPoint, I suppose you should define, togetherkeypoints1andkeypoints2`, another couple of vectors, something like

std::vector<KeyPoint> keypoints1, keypoints2;
std::vector<EllipticKeyPoint> ellkeypoints1, ellkeypoints2;

and, when keypoints1 and keypoints2 al loaded, call convert(); I suppose something like

std::cout << "FOUND " << keypoints1.size() << " keypoints on first image" << std::endl;
std::cout << "FOUND " << keypoints2.size() << " keypoints on second image" << std::endl;

EllipticKeyPoint::convert(keypoints1, ellkeypoints1);
EllipticKeyPoint::convert(keypoints2, ellkeypoints2);

std::cout << "FOUND " << ellkeypoints1.size() << " elliptic keypoints on first image" << std::endl;
std::cout << "FOUND " << ellkeypoints2.size() << " elliptic keypoints on second image" << std::endl;
max66
  • 65,235
  • 10
  • 71
  • 111
  • The exact code is the sample SURF code (3rd link from post). I was hoping to add 1 or 2 lines to it by using the readily available code in opencv library. I tried adding your 1 line of code to the sample code but it didn't work. Using this: `cv::evaluateFeatureDetector(img1.getMat(ACCESS_READ), img2.getMat(ACCESS_READ), H,);` seems to work but I don't understand what the 3rd argument and so on wants. It looks very confusing to me with all the different kinds of symbols. Could you explain what it means? – SK90 Jun 11 '16 at 10:10
  • I mean symbols like "<>,&,*,and ::" and how they fit together are confusing to me since I'm not familiar with C++ – SK90 Jun 11 '16 at 10:27
  • @SK90 - Answer improved to explain (I hope) ho to use `convert()`; about the use of "<>,&,*,and ::", well... you can try asking about single example but it's very difficult give a general answer; C++ is a complex language and I suggest to study it with a good book or a very good tutorial – max66 Jun 11 '16 at 15:04
  • Tried the code but didn't work for me. Will post more specific question. Thanks. – SK90 Jun 16 '16 at 08:03
  • It works. Copy and pasted convert function definition and related template/class/function definitions from evaluation.cpp, and your code to the sample code. – SK90 Jun 16 '16 at 10:30