Ejemplo n.º 1
0
/*
Computes feature descriptors for features in an array.  Based on Section 6
of Lowe's paper.

@param features array of features
@param gauss_pyr Gaussian scale space pyramid
@param d width of 2D array of orientation histograms
@param n number of bins per orientation histogram
*/
void compute_descriptors( CvSeq* features, IplImage*** gauss_pyr, int d, int n)
{
	struct feature* feat;
	struct detection_data* ddata;
	double*** hist;
	int i, k = features->total;

	for( i = 0; i < k; i++ )
	{
		feat = CV_GET_SEQ_ELEM( struct feature, features, i );
		ddata = feat_detection_data( feat );
		hist = descr_hist( gauss_pyr[ddata->octv][ddata->intvl], ddata->r,
			ddata->c, feat->ori, ddata->scl_octv, d, n );
		hist_to_descr( hist, d, n, feat );
		release_descr_hist( &hist, d );
	}
}
Ejemplo n.º 2
0
/*
Computes feature descriptors for features in an array.  Based on Section 6 of Lowe's paper.
@param features array of features
@param gauss_pyr Gaussian scale space pyramid
@param d width of 2D array of orientation histograms
@param n number of bins per orientation histogram
*/
static void compute_descriptors( CvSeq* features, IplImage*** gauss_pyr, int d, int n)
{
	struct feature* feat;
	struct detection_data* ddata;
    double*** hist;//d*d*n的三维直方图数组
    int i, k = features->total;//特征点的个数

    //遍历特征点序列中的特征点
	for( i = 0; i < k; i++ )
	{
        //调用宏,获取序列features中的第i个元素,并强制转换为struct feature类型
		feat = CV_GET_SEQ_ELEM( struct feature, features, i );
        //调用宏feat_detection_data来提取参数feat中的feature_data成员并转换为detection_data类型的指针
		ddata = feat_detection_data( feat );
        //计算特征点附近区域的方向直方图,此直方图在计算特征描述子中要用到,返回值是一个d*d*n的三维数组
		hist = descr_hist( gauss_pyr[ddata->octv][ddata->intvl], ddata->r,
			ddata->c, feat->ori, ddata->scl_octv, d, n );
        //将某特征点的方向直方图转换为特征描述子向量,对特征描述子归一化并将所有元素转化为整型,存入特征点feat中
		hist_to_descr( hist, d, n, feat );
        //释放特征点的方向直方图
		release_descr_hist( &hist, d );
	}
}