RealBasic: Computer Vision -> OpenSURF feature matching


This is the translation of the OpenSURF Computer Vision library from Chris Evans to RealBasic, plus I’ve added some code to compare two pictures. The conversion to RealBasic is not as fast as the C# or C++ version. In fact it is rather slow, but you can use it for educational purposes. If by any chance you’re one of these guys who want to spend some time speeding up this code, please let me know because it can benefit a lot of programmers out there.

SURF (Speeded Up Robust Feature) is a robust local feature detector, first presented by Herbert Bay et al. in 2006, that can be used in computer vision tasks like object recognition or 3D reconstruction.

Christopher Evans on the OpenSURF library:

The task of finding point correspondences between two images of the same scene or object is an integral part of many machine vision or computer vision systems. The algorithm aims to find salient regions in images which can be found under a variety of image transformations. This allows it to form the basis of many vision based tasks; object recognition, video surveillance, medical imaging, augmented reality and image retrieval to name a few.

Simply said:
The concept of feature detection refers to methods to find edges, corners, blobs etc within images that can be used to detect, identify and compare images and is robust against different image transformations like roations, skews, etc…

The code is to complicated to put in this article. The engine is here so you can use it without worrying about the complicated maths. The class has an easy-to-use interface and you can start new Computer Vision experiments with your favorite computer language! :-)

In fact, this is the only code you need to use it:

  ' declare an opensurf and run it on the first image
  OSurf1 = new ABOpenSURF
  OSurf1.ExecuteSURF(Image1,1,true)
  
  ' declare a second opensurf and run it on the second image
  OSurf2 = new ABOpenSURF
  OSurf2.ExecuteSURF(Image2, 1, true)
    
  ' get the matching points between the two images
  OSurf2.GetMatchingPoints(OSurf1)
  
  ' and draw them
  OSurf1.PaintSURF(mBuffer1, DebugMode, true)
  OSurf2.PaintSURF(mBuffer2, DebugMode, true)
  Canvas1.Refresh(true)
  Canvas2.Refresh(true)  

Guess it can’t get any simpler to do such a complicated task :-)

Note 1: An application of the SURF algorithm is patented in the US!
Note 2: In the next article I’ll give you the Realbasic translation of the FAST (Features from Accelerated Segment Test) engine!

The RealBasic implementation of OpenSURF: http://www.gorgeousapps.com/ABopenSURF.zip

Also check out the official OpenSURF library in C++/C#: http://www.chrisevansdev.com/computer-vision-opensurf.html

About these ads

About Alwaysbusy

I'm the lead programmer at One-Two. I like to experiment with new technologies like the Kinect, Computer Vision and A.I. Some of my projects are programmed in more exotic languages like RealStudio and Basic4Android, but also in C# or java. I'll post some of those projects on this blog and I hope you learn some new exciting stuff! View all posts by Alwaysbusy

6 Responses to “RealBasic: Computer Vision -> OpenSURF feature matching”

  • Geoff Perlman

    For what it’s worth, if your code is math-intensive, then the reason it’s slower than C# is because the Real Studio compiler is not an optimizing compiler. However, we are in the process of moving the backend of our compiler to LLVM which IS an optimizing compiler. So once that’s done, your code to speed up considerably.

    • Alwaysbusy

      Thanks for the update Geoff! Looking forward to see what the LLVM compiler is capable of. I’m also experimenting with the RealBasic plugin feature to see where I can gain more speed.

  • Raphael

    GREAT! I tried this myself and did not succeed, neither have the time to make me understand the whole thing. I’m good with RB, but have no clue (yet) on C / Objective C programming or reading and compiling libraries etc.

    Out of that reason – do you think you could show a tutorial on how to compile a cross-platform static library of openCV or for mac / linux and how to use it inside a Real Studio application? Is that possible via declares?

    I would really love to know how to do that and how to interpret the man pages of openCV to continue building with it inside Real Studio.
    I kinda want to unleash the power of the library and MAYBE be able to compile updates myself.

    Or have you succeeded in building a plugin?
    Would be really interested in that.

    Your work is awesome, but atm it really is at least “kind of” slow.

    Thank you very very much for this already !
    I think without you I would possibly really have to learn Objective C before I could do anything with openCV. Now there’s a chance I could work with what I already now and learn C and all the more advanced compiling backgrounds spear over time.

    Best regards,
    Raphael

    • Alwaysbusy

      Hi Raphael,

      Ive tried making OpenCV into a RB lib before but I never succeeded. I’m afraid learning Object C is going to be needed. However, having the java version could help you if you’re willing to translate some code to RB. Some functions (like the above) are real clever but are not using advanced C or java, so you can translate them with ease to RB. I converted some of the OpenCV functions for an inhouse project at OneTwo to create Scaper (some kind of OCR app).

      It does take some time to get browse through the OpenCV code to find what you’re looking for. But It is worth it!

      Cheers!
      Alwaysbusy

  • Raphael

    There also seems to be a Java version. Can’t we link that and use it as well? Except I don’t know how, it should be possible, right? At least with the Monkeybread Plugins?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 79 other followers

%d bloggers like this: