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

标签 c++ opencv types sift feature-descriptor

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 1 4 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值,对吧?这样对吗???不应该是 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/

相关文章:

c# - C# 中的菱形语法

c# - 在 C++ 中获取另一个进程的 session ID

c++ - 从默认参数推导参数包

java - 在 Spring Boot 中将 .csv 文件上传到数据库

Python OpenCV : inRange() stopped working without change

types - ocaml 类型澄清(初学者)

用于 CSV 文件处理的 Java 数据类型

c++ - 将 ASCII std::string 转换为十六进制

c++ - 在内存中实现无限 map

c++ - 纹理坐标不对应于 cv::Mat 坐标