我正在研究 OpenCV 的 SIFT 描述符提取实现。我遇到了一些令人费解的代码来获取兴趣点邻域的半径。下面是带注释的代码,变量名称更改为更具描述性:
// keep octave below 256 (255 is 1111 1111)
int octave = kpt.octave & 255;
// if octave is >= 128, ...????
octave = octave < 128 ? octave : (-128 | octave);
// 1/2^absval(octave)
float scale = octave >= 0 ? 1.0f/(1 << octave) : (float)(1 << -octave);
// multiply the point's radius by the calculated scale
float scl = kpt.size * 0.5f * scale;
// the constant sclFactor is 3 and has the following comment:
// determines the size of a single descriptor orientation histogram
float histWidth = sclFactor * scl;
// descWidth is the number of histograms on one side of the descriptor
// the long float is sqrt(2)
int radius = (int)(histWidth * 1.4142135623730951f * (descWidth + 1) * 0.5f);
我知道这与转换为获取兴趣点的比例有关(我已阅读 Lowe 的论文),但我无法将这些点与代码联系起来。具体来说,我不明白前 3 行和最后一行。
我需要了解这一点才能为运动创建类似的局部点描述符。