如何创建SIFT描述符数据库(图像)? 我的目的是在支持向量机上实施一个监督的训练集。
答案 0 :(得分:0)
您需要哪种图片?如果你不在乎,你可以下载一些公共计算机视觉数据集,如http://lear.inrialpes.fr/~jegou/data.php#holidays,它提供图像和已经计算出来自其区域的SIFT。 或者尝试其他数据集,例如http://www.cvpapers.com/datasets.html
其他可能性只是下载\制作大量照片,检测兴趣点并用SIFT描述它们。可以使用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;
}