【问题标题】:What is the right output type of SIFT descriptors on OpenCV?OpenCV 上 SIFT 描述符的正确输出类型是什么?
【发布时间】:2014-08-16 11:05:04
【问题描述】:

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 67 14 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 值,对吧?这样对吗???不应该是浮动吗?

【问题讨论】:

  • 是的,没错。它是浮点数,然后乘以 512 进行缩放 - 这就是为什么 is 是整数。
  • 乘以 512?为什么?没听懂...我可以在不进行缩放/倍增的情况下保存它们吗?
  • 哇!我从另一个问题中得到了答案:stackoverflow.com/questions/14911770/… 无论如何,谢谢。 :-)

标签: c++ opencv types sift feature-descriptor


【解决方案1】:

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

这是因为经典的 SIFT 实现量化了归一化的 浮点值通过 512 转换为 unsigned char 整数 乘数,相当于考虑任何 SIFT 分量在 [0, 1/2] 之间变化,从而避免精度降低 尝试对整个 [0, 1] 范围进行编码。

抱歉重复... =S

【讨论】:

    猜你喜欢
    • 2017-04-23
    • 2015-11-18
    • 1970-01-01
    • 2012-04-01
    • 2015-02-01
    • 2012-10-07
    • 1970-01-01
    • 1970-01-01
    • 2017-01-08
    相关资源
    最近更新 更多