您的位置:首页 > 其它

读取sift点数据函数

2017-08-10 16:34 141 查看
从硬盘读取SIFT特征点数据,这些数据是David Lowe的程序生成的,不包含读取描述。
http://www.cs.ubc.ca/~lowe/keypoints/
readsift.h

#pragma once

#include <vector>

struct SiftPoint {
double x;
double y;
double scale;
double orientation;
};

bool loadSiftPoints(const char* nameFile, std::vector<SiftPoint>& siftPoints);

readsift.cpp
#include "readsift.h"
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>

bool loadSiftPoints(const char* nameFile, std::vector<SiftPoint>& siftPoints)
{
siftPoints.clear();
std::ifstream ifile(nameFile);
int numPoints;
if(ifile.good())
{
std::string str;
std::getline(ifile, str);
std::istringstream s(str);
s >> numPoints;
while (ifile.good())
{
std::string str;
std::getline(ifile, str);
if (ifile.good())
{
std::istringstream s(str);
SiftPoint sp;
s >> sp.x >> sp.y >> sp.scale >> sp.orientation;
if (!s.fail())
siftPoints.push_back(sp);
}
}
}
ifile.close();
return (!siftPoints.empty()) && (numPoints== siftPoints.size());
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐