Showing posts with label SIFT. Show all posts
Showing posts with label SIFT. Show all posts

Sunday, December 20, 2015

Using SIFT/SURF for Object Recognition in OpenCV Java

Hi All,

Today my post is on, how you can use SIFT/SURF algorithms for Object Recognition with OpenCV Java. I have shared this post on SURF feature detector previously. This is fully based on that post and therefore I'm just trying to show you how you can implement the same logic in OpenCV Java. It's important that you have to download previous OpenCV versions, so that you have SURF feature detector in your library. Because in the newer versions they have removed these Non-Free modules from the java wrapper. You can check this out.

I believe that you have some basic knowledge in working with OpenCV Java. If you want some beginner help you can refer the following links.
Now let's move on to our development. I'm using Eclipse for developing this. I'm going to use OpencCV 2.4.11. You can download it here

First create the user library for OpenCV as described in the previous link and add it to the build path. Then we can start developing the code for object recognition. Following is my eclipse project. I have added the OpenCV 2.4.11 library as a user library and added it to the build path. 

I'm using following images for object recognition. 

1. Object we are going to recognize. 

2. Scene that we are going to recognize the object from. 

Now following is the Java implementation of our SURF feature detector. 



Following are our outputs. 

1. Identified key-points of the object.



2. Matching the object keypoints with the scene. 


3. Object recognized image. 


You can do the same with SIFT feature detector by just changing the Feature Detector and Descriptor Extractor name to SIFT. 

So that's it. 

Hope that helps. 

Thank You. :-)