what is the purpose of cos_t/=hist_width in OpenCV SIFT

asked 2020-04-30 15:06:47 -0500

Hugheschen gravatar image

Hello fellows,

I am digging into the source code of the SIFT in OpenCV, and I encountered a few lines of code that I can't justify. In the calcSIFTDescriptor portion, this function takes the input "ori" and calculate its respectful cos and sin. as the 2 lines shown below:

float cos_t = cosf(ori*(float)(CV_PI/180));                                                                       
float sin_t = sinf(ori*(float)(CV_PI/180));

A few lines later the cos_t and sin_t are divided by "hist_width" without being used by the 2 lines indicated below:

cos_t /= hist_width;                                                                                          
sin_t /= hist_width;

Then this modified cos_t and sin_t is used for rotation.

        float c_rot = j * cos_t - i * sin_t;
        float r_rot = j * sin_t + i * cos_t;

I find it hard to understand why the source code update the cos_t and sin_t by dividing them by hist_width. Any help would be appreciated!



edit retag flag offensive close merge delete