SURF and OpenSURF : Usage of OpenSURF library

As I said before OpenSURF is an open source implementation of SURF library, which is being used for feature extraction and matching. In my last post I have provided the results of my experimentation. This post is for description of the methods and how to do it all by yourself.

Well, first of all you need to configure your IDE for using openCV dlls and libs. Then add the openSURF library to your project(else for testing you can create inside openSURF project e.g. see main.cpp). All you need is to include “surflib.h” from the openSURF library which contains all the main function you need for the implementation.

The main functions are :

//! Library function builds vector of described interest points  (from surflib.h)
inline void surfDetDes(IplImage *img,  /* image to find Ipoints in */
std::vector<Ipoint> &ipts, /* reference to vector of Ipoints */
bool upright = false, /* run in rotation invariant mode? */
int octaves = OCTAVES, /* number of octaves to calculate */
int intervals = INTERVALS, /* number of intervals per octave */
int init_sample = INIT_SAMPLE, /* initial sampling step */
float thres = THRES /* blob response threshold */)

//To get matches between two Ipoints (from ipoints.h)
void getMatches(IpVec &ipts1, IpVec &ipts2, IpPairVec &matches);

//! Draw all the Ipoints in the provided vector (from utils.h)
void drawIpoints(IplImage *img, std::vector<Ipoint> &ipts, int tailSize = 0);

//! Save the SURF features to file (from utils.h)
void saveSurf(char *filename, std::vector<Ipoint> &ipts);

//! Load the SURF features from file ( from utils.h)
void loadSurf(char *filename, std::vector<Ipoint> &ipts);

So as the very first function says, it calculates all the ipoints(Interest Points) from the image and stores them in the ipts vector.

As indicated by comments, the drawIpoints(…) method draws the interest points found by the previous method, saveSurf(…) saves the ipoints to a file and loadSurf(…) loads the ipoints from a file to a variable.

So once all interest points of the image are found, you can match them to the interest points of another image by the getMatches(), which stores all the matched points to the matches variable. The definition of IpPairVec is

typedef std::vector<std::pair<Ipoint, Ipoint> > IpPairVec;

So in case you want to connect all the match points by cvLine you can use the following code snippet (see the 5th procedure in main.cpp)

  for (unsigned int i = 0; i < matches.size(); ++i)
  {
    drawPoint(img1,matches[i].first);
    drawPoint(img2,matches[i].second);

    const int & w = img1->width;
    cvLine(img1,cvPoint(matches[i].first.x,matches[i].first.y),cvPoint(matches[i].second.x+w,matches[i].second.y), cvScalar(255,255,255),1);
    cvLine(img2,cvPoint(matches[i].first.x-w,matches[i].first.y),cvPoint(matches[i].second.x,matches[i].second.y), cvScalar(255,255,255),1);
  }

So this is all for now, I will keep you updated about my work !

So as the very first function says, it calculates all the ipoints(Interest Points) from the image and stores them in the ipts vector.

9 thoughts on “SURF and OpenSURF : Usage of OpenSURF library

  1. I have a question Amit. Thanks for your wonderful post btw.

    If i have 2 images and I get a list of vectors that match: what should be my test to say that the images closely match or not?

    Assume I want to match 2 images (an original source and another one that has beenc compressed or something).I get the point of interest from both the images ans compute the match vector. what next? what will tell me whether those 2 images are close or not?

    Thanks in advance

  2. What do you think that is better, OpenSurf or SURF implementation of OpenCV 2.2?

    Nice blog 🙂

    Wiliam.

  3. Amit. Thanks for your wonderful post btw.
    I have exactly the same question as that of guna. so i am repeating his/her wordings again.
    please any one give me reply

    If i have 2 images and I get a list of vectors that match: what should be my test to say that the images closely match or not?
    Assume I want to match 2 images (an original source and another one that has beenc compressed or something).I get the point of interest from both the images ans compute the match vector. what next? what will tell me whether those 2 images are close or not?
    Thanks in advance

  4. Hi Amit!
    I want to use open SURF for recognition in AR in iPhone.I don’t know how to get ModelView matrix of the object in camera frames. Please guide me that is there any utility function or any tutorial, code or book so that I could get the concept. Please guide me. Thanks a lot in advance.

  5. Amit

    Thanks for the wonderful discussion . I am working on a project which need to detect copy move image manipulation . I am using the c# version . In this project it is needed to match the features with the same image , if copy move has been done then it ca be detected . Please help me with how can i do features matching with a same image .

    Thanks and Regards
    Somu

  6. Hi, Amit
    I’ve run this open surf library using Visual Studio 2008 and OpenCV 2.0
    But ,, these errors are found
    ………………..

    1>c:\users\tooooona\desktop\surf code\3 c++\opensurf\opensurfcpp\src\ipoint.h(29) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int

    1>c:\users\tooooona\desktop\surf code\3 c++\opensurf\opensurfcpp\src\ipoint.h(29) : error C2146: syntax error : missing ‘,’ before identifier ‘src_corners’

    1>c:\users\tooooona\desktop\surf code\3 c++\opensurf\opensurfcpp\src\kmeans.h(111) : error C2065: ‘FLT_MAX’ : undeclared identifier

    1>c:\users\tooooona\desktop\surf code\3 c++\opensurf\opensurfcpp\src\main.cpp(145) : error C2660: ‘translateCorners’ : function does not take 3 arguments

    ————
    Could you help me, please?

Leave a comment