10/27/2011

Sift matching C++ source code / using opencv library

Created Date : 2011.10
Language : C/C++
Tool : Microsoft Visual C++ 2008
Library & Utilized : OpenCV 2.3
Reference : SIFT reference
etc. : template Image, WebCam







I made SIFT matching program using OpenCV 2.3.
I was wondering how to know the object pose.
In the internet, there are many source about sift, surf. But most of code introduced about only descripter and matching. There is no code to find object pose.
So I made this code and I should disclose this code.


This code uses openCV functions very useful.
cvExtractSURF, cvFindHomography...

I made matching code to the class. Class file name is MareMatchingClass.h/cpp.
You can use my class in the source very easily.

1. Create Matching class
   CMareMatchingClass MMathing;   

2.Input PatchImg
   MMathing.ExtractPatchSurf(PatchImg);

3.Find PatchImg in the background img
   MMathing.GetObjectRectAndBestH(BackGroundImg, &rect4pt);

4.Drawing the rect(rect4pt).
5.Repeat, go to the 3.

The class is consist of like below process;
1. Extract Feature -> use cvExtractSURF function
2. Find Matching point
3. Select some feature in the mached feature points, randomly.
4. calculate Homography matrix. This is geometry relationship between patch and background image.
5. transform features in the patch image by Homography matrix.
6. compare the transformed features to the background features.
7. evaluate how much is the homography exact.
7. repeat 4~6 and select best H.


<source code>

I think the source code is not best.
There are still shortage the source code.
It would need futher improvemnet.
so I want to discuss with you. Please leave your valueable opinion.
Thank you.
Have a nice day~. ^^

Oh~ english is very difficult.....


19 comments:

  1. Code doesn't works as it works in your video,

    Why is that>?

    ReplyDelete
  2. I cann't know your problem.
    What error did you meet?

    ReplyDelete
  3. Anonymous15/8/12 01:34

    Hi Mare,your above code is very useful.But its not working Properly.I am working in Image mode. I have given 2 images(patch image and background image).The code fails in FindBestH().And if(inCount <= 5) returning 0.It can't draw line on background image.

    Can you please guide me.I can successfully compile the code.

    ReplyDelete
  4. Could you send me your source code and image file?
    I will check what the problem is.
    My e-mail is feelmare@daum.net or feelmare@gmail.com.

    I guess the problem is lack of input feature or not approporiate input value.
    Thank you.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thanks for the great tutorial and it is very helpful in my studies but there is a problem the problem is too slow almost running in 1 frame or 2 frames a per second. Is there anyway how to speed up the program?

    Thanks in advance!

    ReplyDelete
    Replies
    1. I think the source code is not complete.
      I made this code to study principle of SIFT.
      I want to help to others study.

      Delete
  7. It is possible to use Mat image in the program?

    ReplyDelete
    Replies
    1. I made iplImage class base.
      If you want to Mat, a lot of parts will have to be modified.
      Thank you.

      Delete
  8. Anonymous15/9/13 08:45

    i could not find the code hear, has it been removed?

    ReplyDelete
  9. em.. I just checked down is possible or not.
    Click the linked words '< source code >' then page will move to docs.google.com.
    And you can download.
    Thank you.

    ReplyDelete
  10. Anonymous4/4/14 05:27

    oh man what is this!!

    ReplyDelete
  11. to test the code which file should i open?
    thank you
    im beginner

    ReplyDelete
  12. main.cpp is main source code.
    but if you use Visual Studio, you can open by project.
    xxx.sin file is project opner file.
    Thank you.

    ReplyDelete
  13. i could not find the code hear, has it been removed?

    ReplyDelete
  14. Before you go out purchasing computer connections from the Internet, you ought to think about some significant variables. razer viper

    ReplyDelete
  15. An investigation by Centers for Disease Control and Prevention (2010) found that solitary 20% of the registration blocks are inside a large portion of a mile of a square limit. VMake Video Editor Mod APK

    ReplyDelete