OpenCV上SIFT描述符的正确输出类型是什么?
我问这是因为我知道它是 float / double ,但是当我尝试将描述符保存在文件上时,它会保存一些 int 值...
我的代码:
cv::Mat img;
std::vector<cv::KeyPoint> imgKeypoints;
cv::Mat imgDescriptors;
cv::DescriptorExtractor *extractor;
cv::FeatureDetector *detector;
img = cv::imread(this->imageFileName.c_str(), cv::IMREAD_GRAYSCALE);
detector = new cv::DenseFeatureDetector(15.0, 1, 0.1, 6, 0, true, false);
extractor = new cv::SIFT(0, 3, 0.04, 10.0, 1.6);
extractor->compute(this->img, this->imgKeypoints, this->imgDescriptors);
std::ofstream fout(outputFile.data());
//I need to save it on this specified format
for (int i = 0; i < this->imgDescriptors.rows; i++)
{
for (int j = 0; j < this->imgDescriptors.cols; j++)
fout << " " << float(this->imgDescriptors.at<float>(i,j));
}
输出文件如下:
0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 10 13 10 1 1 0 24 5 2 3 5 1 0 5 0 0 0 0 0 0 0 0 3 3 7 4 2 1 2 2 23 13 27 30 35 19 21 35 96 16 15 35 43 12 9 123 0 0 0 0 0 0 0 0 1 1 1 2 2 4 7 7 45 8 27 66 27 17 41 127 57 18 82 100 67 14 16 90 0 0 0 0 0 0 0 0 6 0 1 17 9 1 2 30 143 26 50 168 168 4 5 107 168 58 86 168 74 14 5 54
它们都是 int 值,对吗?这样对吗???不应该漂浮吗?
答案 0 :(得分:1)
哇!我从另一个问题得到答案:How does the SiftDescriptorExtractor from OpenCV convert descriptor values?
这是因为经典的SIFT实现量化了规范化 浮点值到512的无符号字符整数 乘数因子,相当于考虑任何SIFT 分量在[0,1 / 2]之间变化,从而避免松动精度 试图编码完整的[0,1]范围。
抱歉重复... = S