如何创建 SIFT 描述符(图像)数据库?我的目的是在支持向量机上实施一个有监督的训练集。
问问题
1137 次
1 回答
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;
}
于 2013-11-08T01:19:06.457 回答