kl3m3n's blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Scale-invariant feature transform source code&DLL

Klemen
Active Participant

In one of my previous posts, I have been testing the openCV SIFT algorithm. I have cleaned and improved the code and used a couple of different input images. The results are shown below.

I am also attaching the source c++ code, the DLL and labview code that calls the DLL. For an image of VGA size (640x480 pixels) the SIFT algorithm takes about 500 ms (with my poor coding at least ). The modification to use SURF algorithm is then simple. Note that the algorithm uses default parameters that cannot be altered with the attached code. But again, to extend the code to be able to change the parameters is also simple. Code is compiled with VS2010 x86 and OpenCV 2.4.5. Add  "...\opencv\build\x86\vc10\bin" to system path or recompile the source code yourself.

1.png

2.png

3.png

4.png

Be creative.

Post edited on 30.8.2013

I saw that I have made some error in the previous code (the LV example program, where the u offset of the matched points was off - the wire "x image size" was connected from the wrong image). I have corrected this and updated the code so you can modify the parameters of the SIFT algorithm in Labview. The code also calculates the homography, which can be used to map the corresponding points from one image to another (see the image below). This can be used for object tracking.

sift_homography_openCV_FP.jpg

Note, that the dll was built with OpenCV 2.4.6 so you need to install it (and add to system path) or recompile the source code yourself. The LV example is attached also (version 2010).

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Comments
lizhuo_lin
Member

Hello! klemen

I test your code, but LabVIEW come out this error未命名1.jpg

I already add the path of opencv to system variables, am I do something wrong?

未命名.jpg

CLD
CAU
Klemen
Active Participant

Hello,

I have version 2.4.5 so the correct path in the system variables (under "Path") is:

C:\Program Files (x86)\OpenCV 2.4.5\opencv\build\x86\vc10\bin.

If this doesn't work, try building the DLL again with the attached source code. Post back if you have any problems.


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
lizhuo_lin
Member

Hello! Klemen

Thank for your kind reply!

I install the same version opencv with you, and the path is : E:\TDDOWNLOAD\opencv

so I set the system variables as followed :E:\TDDOWNLOAD\opencv\build\x86\vc11\bin

I think this is not matter. cause I test your newest code Histogram matching and GrabCut, both code can run well.

the ERROR 1097 occurred in the first CLN named image.

Because I do not install Visual Studio 20**, I will find someone to help me to rebuild the DLL.

and your code is very good!

CLD
CAU
Klemen
Active Participant

Hello,

this is strange,since all dll's were built using the same settings. Also,i re-downloaded the code and the dll is built ok,as it works for me.  Strange...

Try using vc10 instead of vc11 in the path.It was bulit in VS2010.

Anyway,I hope you can get it to work.

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
lizhuo_lin
Member

Hello!

you are right, I change system variables from E:\TDDOWNLOAD\opencv\build\x86\vc11\bin to :E:\TDDOWNLOAD\opencv\build\x86\vc10\bin, the code run very well, it seems that the version of VC affect the calling of DLL in LabVIEW.

Thanks again!

CLD
CAU
jibinalla
Member

Hello!

Im trying to run this program but unfortunately a system error appears. I did change the system variables and eI think I correctly installed OpenCV in my computer but the program is looking for opencv_calib3d246.dll unforunately I couldnt find any lower versions of opencv and Im stuck in using versions 2.4.9 or 2.4.10 I tried recompiling the code you attached but sadly I could not even rebuild it due to so many errors. I dont know much about C++ but I was hoping if there is a way around this problem to to at least tell LabVIEW not to look for opencv_calib3d246.dll or update it to opencv_calib3d249.dll

Thanks!

Klemen
Active Participant

Hello,

find the rebuilt .dll in the attachment of the post. I have used the same code but with OpenCV 2.4.9 dependencies. I don't know why you got the errors.

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
jibinalla
Member

Hello,

Thankyou for rebuilding the code!!! I appreciate it so much! the program works now with the new dll file. I believe its not the code but visual studio itself having some problems. Ill try to reconfigure visual studio again with OpenCV 2.4.9, anyway thanks again for the reply!

Cheers!!!

magicfrog
Member

Hello, first of all congratulations for software development. I need some information.

Can I apply your project directly to two stereoscopic cameras and obtain, in real time, the distance between the cameras and the object? What kind of changes should I make to your files?

I state that I unfortunately do not know anything for OpenCV.

Best regards

M

Castro_QMT
Member

Hello nice work.

 

I've tried rebuilding your DLL to x64 it builds fine, but when i use it on LabVIEW it reports:

Error 1097 occurred at Call Library Function Node in sift_openCV.vi

Possible reason(s):

LabVIEW: An exception occurred within the external code called by a Call Library Function Node. The exception might have corrupted the LabVIEW memory. Save any work to a new location and restart LabVIEW.

 

When executing function name: Image.