19年1月份的慕尼黑,大雪纷飞...
各位看官,最近在线特征相关的研究,本文把直线特征的提取和匹配的源码贴一下,希望对大家有所帮助,在下使用 OpenCV下的LSD 提取特征,LBD进行特征描述, KNNMatch做特征描述。同时,还有特征质量的简单筛选。
#include <iostream>
#include <chrono>
#include <cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/line_descriptor/descriptor.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <iostream>
using namespace cv;
using namespace std;
using namespace cv::line_descriptor;
struct sort_descriptor_by_queryIdx
{
inline bool operator()(const vector<DMatch>& a, const vector<DMatch>& b){
return ( a[0].queryIdx < b[0].queryIdx );
}
};
struct sort_lines_by_response
{
inline bool operator()(const KeyLine& a, const KeyLine& b){
return ( a.response > b.response );
}
};
void ExtractLineSegment(const Mat &img, const Mat &image2, vector<KeyLine> &keylines,vector<KeyLine> &keylines2);
int main(int argc, char**argv)
{
if(argc != 3)
{
cerr << endl << "Usage: ./Line path_to_image1 path_to_image2"