gpt4 book ai didi

c++ - OpenCV 上 SIFT 描述符的正确输出类型是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 22:58:21 27 4
gpt4 key购买 nike

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 5 1 1 2 2 4 7 7 45 8 27 66 27 17 41 127 57 18 82 100 66 9014 1 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值,对吧?这样对吗???不应该是 float 吗?

最佳答案

哇!我从另一个问题得到了答案:How does the SiftDescriptorExtractor from OpenCV convert descriptor values?

This is because classical SIFT implementations quantize the normalized floating point values into unsigned char integer through a 512 multiplying factor, which is equivalent to consider that any SIFT component varies between [0, 1/2], and thus avoid to loose precision trying to encode the full [0, 1] range.

抱歉重复了... =S

关于c++ - OpenCV 上 SIFT 描述符的正确输出类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24416215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com