下你所需,载你所想!
汇集开发技术源码资料

Opencv3中SIFT算法带详细注释

:13.982KB :1 :2022-08-28 22:34:39

部分简介

Opencv3中SIFT算法详解如果开发者对于本文件有需要的可以参考。
整理SIFT算法,带详细注释!
tatic void mycalcSIFTDescriptor(const Mat& img, Point2f ptf, float ori, float scl,
int d, int n, float* dst)
{ //d=4 n=8
//计算余弦,正弦,CV_PI/180:将角度值转化为幅度值
Point pt(cvRound(ptf.x), cvRound(ptf.y));
float cos_t = cosf(ori*(float)(CV_PI / 180));
float sin_t = sinf(ori*(float)(CV_PI / 180));
float bins_per_rad = n / 360.f;//45°
float exp_scale = -1.f / (d * d * 0.5f);
float hist_width = mySIFT_DESCR_SCL_FCTR * scl;
// 计算图像区域半径mσ(d 1)/2*sqrt(2)
// 1.4142135623730951f 为根号2
int radius = cvRound(hist_width * 1.4142135623730951f * (d 1) * 0.5f);
// Clip the radius to the diagonal of the image to avoid autobuffer too large exception
radius = std::min(radius, (int)sqrt(((double)img.cols)*img.cols ((double)img.rows)*img.rows));
cos_t /= hist_width;
sin_t /= hist_width;

int i, j, k, len = (radius * 2 1)*(radius * 2 1), histlen = (d 2)*(d 2)*(n 2);
int rows = img.rows, cols = img.cols;

AutoBuffer buf(len * 6 histlen);
float *X = buf, *Y = X len, *Mag = Y, *Ori = Mag len, *W = Ori len;
float *RBin = W len, *CBin = RBin len, *hist = CBin len;

热门推荐

相关文章