如何克隆SIFT的描述符数据库 [英] How to crete a SIFT's descriptors database

查看:231
本文介绍了如何克隆SIFT的描述符数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建SIFT描述符(图像)的数据库?
我的目的是在支持向量机上实施受监督的培训集。

How do I create a database of SIFT descriptors (of images)? My intention is to implement a supervisioned training set on Support Vector Machine.

推荐答案

?如果你不关心,你可以下载一些公共计算机视觉数据集,如 http:/ /lear.inrialpes.fr/~jegou/data.php#holidays ,它提供了图像和已经计算的SIFT从其区域。
或尝试其他数据集,例如,从 http://www.cvpapers.com/datasets。 html

Which kind of images do you need? If you don`t care, you can just download some public computer vision dataset like http://lear.inrialpes.fr/~jegou/data.php#holidays which offers both images and already computed SIFTs from its regions. Or try other datasets, for instance, from http://www.cvpapers.com/datasets.html

其他可能性只是下载\制作大量照片,检测兴趣点并使用SIFT来描述它们。可以使用 OpenCV VLFeat 或其他库。

Other possibility is just to download\make lots of photos, detect interest point and describe them with SIFTs. It can be done with OpenCV, VLFeat or other libraries.

OpenCV示例。

OpenCV example.

    #include <opencv2/opencv.hpp>
    #include <opencv2/nonfree/nonfree.hpp>
    #include <fstream>


    void WriteSIFTs(std::vector<cv::KeyPoint> &keys, cv::Mat desc, std::ostream &out1)
    {
      for(int i=0; i < (int) keys.size(); i++)
        {
          out1 << keys[i].pt.x << " " << keys[i].pt.y << " " << keys[i].size << " " << keys[i].angle << " "; 
//If you don`t need information about keypoints (position, size) 
//you can comment out the string above

          float* descPtr = desc.ptr<float>(i);
          for (int j = 0; j < desc.cols; j++)
              out1  << *descPtr++ << " ";
          out1 << std::endl;
        }

    }


    int main(int argc, const char* argv[])
    {
      const cv::Mat img1 = cv::imread("graf.png", 0); //Load as grayscale

      cv::SiftFeatureDetector detector;
      std::vector<cv::KeyPoint> keypoints;
      detector.detect(img1, keypoints);

      cv::SiftDescriptorExtractor extractor;
      cv::Mat descriptors;
      extractor.compute(img1, keypoints, descriptors);

      std::ofstream file1("SIFTs1.txt");
      if (file1.is_open())
        WriteSIFTs(keypoints,descriptors,file1);
      file1.close();
      return 0;
    }

这篇关于如何克隆SIFT的描述符数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆