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

有帮助吗?

解决方案

您需要哪种图像?如果您不在乎,您只能下载一些公共计算机视觉数据集 http://lear.inrialpes.fr/~jegou/data.php#holidays 它提供了图像,并且已经从其地区进行了筛选。或尝试其他数据集,例如 http://www.cvpapers.com/datasets.html

其他可能性只是下载制作大量照片,检测兴趣点并用筛分描述它们。可以完成 OPENCV, vlfeat 或其他库。

OPENCV示例。

    #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;
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top