Life is a game, take it seriously

SURFmex bugs

In Computer Vision, Matlab on May 8, 2011 at 9:46 am

written by Gooly

Continuing the last post, I have to mention some bugs in SURFmex that needed to be noticed.

First, be aware of the orientation the SURFPOINTS function give back. It is in a counter clockwise direction, however if you try to plot on Matlab, the column row axis is in the clockwise direction; it is easy to get confused and have the wrong direction. Actually this is one of the mistakes in the surfplot function given by SURFmex under the common folder. Another bug is the degree to radian problem, be aware that the SURFPOINTS function gives the orientation in degree; the surfplot function uses it assuming it is radian instead. Change the surfplot function as follows to correct the bugs.

```function surfplot(points,info)

colorline= {'r-','b-','c-','g-','m-'};
phi = linspace(0,2*pi);
x = cos(pi/2 + phi);
y = sin(pi/2 + phi);
bbox = [x 0; y 0];

for k = 1:size(points,2)
scale = info(1,k);
ori   = -info(3,k)*pi/180;

R = [cos(ori) -sin(ori);sin(ori) cos(ori)];

pbox = scale*R*bbox + points(:,k)*ones(1,size(bbox,2));
hold on;
plot(pbox(1,:),pbox(2,:),colorline{mod(k,5)+1});
end
end
```

Another bug is an OpenCV bug, an error would occur if you input a pretty flat image which it couldn’t find any interest points. A work around of this is to check if it’s a flat image before calling SURFPOINTS, since if it’s a flat image, you probably wouldn’t want to match it; or you can do a histogram equalization before calling SURFPOINTS, this would solve the problem.

1. […] move to another OS. Note that you have to fix the surfplot function bug in the common folder, see this explanation. Next, put the library in the project folder and remember to right click on it and add to path. […]

2. Excellent blog, with the very latest computer vision technologies.

• Thanks :)

3. I just checked the code on my computer. It didn’t have the radians/degrees bug. But the .zip archive available online did. I must have forgot to update it. Oh well.

• Sorry that I forgot to send you an email about the bug, I just thought that its not a big problem and is too busy recently. Thanks for the library, it’s great :)

4. hi,Gooly~
I’m taco from Taiwan, I love your blog, and I like SURF!!~
I’m trying to make( by running make.m) SURFmex myself, because I want to turn the ‘upright’ option off, for faster and robuster matching. In openCV the ‘upright’ option exist, but not in SURFmex, so I add some code in surfpoints.cpp as below

int nfield = mxGetNumberOfFields(mxoptions);
for (int field=0;field<nfield;++field) {

else if (getOptionsField(mxoptions,field,"upright",value)) {
params.upright = value;
}

but it failed when I convert the cpp into mex

nice to meet you~

• Thanks,
You should be able to find out why by searching the error message, I am not an expert in converting cpp to mex so probably can’t help you. But I know the old version of SURFmex do have the upright option, but it isn’t using the OpenCV library; they probably took it out for simplicity.

Best Regards,

5. i’m from indonesia and now still study about surf…thanks for information dude..you awesome….i hope i can understand about surf so much..amien..:)

• Thanks, I am pretty sure you’ll understand if you really want to

6. Thank you very much for the article. It helped me alot!

7. Hey,

Can you help me PLZ,
I have some problem’s when i compile “surfpoints.cpp” and “surfmatch.cpp” under matlab;
i have this :

>>mex surfpoints.cpp
In file included from surfpoints.cpp:21:
cppmatrix.h: In member function ‘void matrix::init(const mxArray*) [with T = unsigned char]’:
cppmatrix.h:32: instantiated from ‘matrix::matrix(const mxArray*) [with T = unsigned char]’
surfpoints.cpp:59: instantiated from here
cppmatrix.h:37: error: ‘~matrix’ is not a member of ‘matrix’

mex: compile of ‘ “surfpoints.cpp”‘ failed.

??? Error using ==> mex at 207
Unable to complete successfully.

• If I remembered it correctly, surfmex is already compiled, so you don’t need to do mex again.

8. Hi,I want multiple object recognition, kindly tell me procedure.Because the current surfMex code take more time for matching only one image.

• What algorithm are you using for recognition? There are many ways to save computation when multiple objects appear.