Ask Your Question

SIFT implementation in openCV

asked 2016-12-03 06:00:41 -0500

Paco_87 gravatar image

Hi, I' ve tried to understand sift implementation in opencv. In sift.cpp class there is 'calcSIFTDescriptor' method; here, there are two for cycles: for( i = 0; i < d+2; i++ ) {...} and for( i = -radius, k = 0; i <= radius; i++ ) {...}. What is their meaning? Also, do you know some web sites or some documents that explain (better than openCV tutorial or refman) how sift algorithm in opencv works?

edit retag flag offensive close merge delete


LBerger gravatar imageLBerger ( 2016-12-03 06:23:22 -0500 )edit

To understand the method before the implementation: Distinctive Image Features from Scale-Invariant Keypoints, Wikipedia, etc.

Eduardo gravatar imageEduardo ( 2016-12-03 16:56:34 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-05 02:40:58 -0500

Vintez gravatar image

updated 2016-12-05 02:42:27 -0500

Well the first loop for( i = 0; i < d+2; i++ ) {...} is used, to fill the Histogramm of the descriptor where d is the width of the descriptor + 2 (e.g. with the 128 elements vector 4 + 2). It is initially filled with zeroes, so it would not occur the possibility, that a histogram bin would point to null instead of a value.

The second loop for( i = -radius, k = 0; i <= radius; i++ ) {...} is used pick the pixel values around the certain keypoint and to calculate the orientation and magnitude of it. The radius value determines what size this window where pixels will be looked up have. e.g. if radius is 15 the algorithms lookup window of the KeyPoint 100,100 would be a rectangle with the upperLeft and bottomRight coordinates 85, 85 and 115, 115

If you still don't know what is meant, I strongly suggest you to read a good tutorial about the theory of the algorithm.

edit flag offensive delete link more


I understand you. However I have an issue: when I declare "SIFT detector( 100 );" in my main program, I say that I want 100 keypoints in my image. Considering that I specified only one parameter, this instruction calls "operator()" method in sift.cpp file. But here, there's only one instruction: "(*this)(_image, _mask, keypoints, noArray());". What is the meaning?

Paco_87 gravatar imagePaco_87 ( 2016-12-12 03:59:52 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-12-03 05:59:39 -0500

Seen: 159 times

Last updated: Dec 05 '16