虽然我知道角度和八度的概念,但我想知道float angle是什么意思,所以我查看了OpenCV2.3.1的源代码
在sift.cpp
inline KeyPoint featureToKeyPoint( const feature& feat )
{
float size = (float)(feat.scl * SIFT::DescriptorParams::GET_DEFAULT_MAGNIFICATION() * 4); // 4==NBP
float angle = (float)(feat.ori * a_180divPI);
return KeyPoint( (float)feat.x, (float)feat.y, size, angle, feat.response, feat.feature_data->octv, feat.class_id );
}
好的,我得到了角度定义,但是 feat.ori 和 a_180divPI 是什么
后者很容易找到
const double a_180divPI = 180./CV_PI;
前者需要一些努力,经过几个方法,我得到了
struct feature
{
double x; /**< x coord */
double y; /**< y coord */
double scl; /**< scale of a Lowe-style feature */
double ori; /**< orientation of a Lowe-style feature */
...
};
feat.ori 是根据 Lowe 的论文 (http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf) 通过几个步骤计算出来的,包括计算 ori_hist、平滑直方图和 add_good_ori_feature。
我不是 100% 确定 ori 的确切含义,但我强烈怀疑 OpenCV 是否已将 ori 转换为适当的弧表示,最终结果 angle 是从 -180 开始的正常含义天使范围度到 180 度。证据是
1) ori = arctan2( dy, dx)
2) bin = cvRound( n * ( ori * CV_PI ) / PI_2 )
3) new_feat->ori = ( ( PI2 * bin ) / n ) - CV_PI;
希望能帮到你