资源简介
Feature::Feature(const string& detectType, const string& extractType, const string& matchType)
{
assert(!detectType.empty());
assert(!extractType.empty());
assert(!matchType.empty());
m_detectType = detectType;
m_extractType = extractType;
m_matchType = matchType;
initModule_nonfree();
}
代码片段和文件信息
// 局部图像特征提取与匹配
// Author: www.icvpr.com
// Blog : http://blog.csdn.net/icvpr
#include “LocalFeature.h“
Feature::Feature()
{
m_detectType = “SIFT“;
m_extractType = “SIFT“;
m_matchType = “FruteForce“;
initModule_nonfree();
}
Feature::~Feature()
{
}
Feature::Feature(const string& detectType const string& extractType const string& matchType)
{
assert(!detectType.empty());
assert(!extractType.empty());
assert(!matchType.empty());
m_detectType = detectType;
m_extractType = extractType;
m_matchType = matchType;
initModule_nonfree();
}
void Feature::detectKeypoints(const Mat& image std::vector& keypoints)
{
assert(image.type() == CV_8UC1);
assert(!m_detectType.empty());
keypoints.clear();
m_detector = FeatureDetector::create(m_detectType);
m_detector->detect(image keypoints);
}
void Feature::extractDescriptors(const Mat& image std::vector& keypoints Mat& descriptor)
{
assert(image.type() == CV_8UC1);
assert(!m_extractType.empty());
m_extractor = DescriptorExtractor::create(m_extractType);
m_extractor->compute(image keypoints descriptor);
}
void Feature::bestMatch(const Mat& queryDescriptor Mat& trainDescriptor std::vector& matches)
{
assert(!queryDescriptor.empty());
assert(!trainDescriptor.empty());
assert(!m_matchType.empty());
matches.clear();
m_matcher = DescriptorMatcher::create(m_matchType);
m_matcher->add(std::vector(1 trainDescriptor));
m_matcher->train();
m_matcher->match(queryDescriptor matches);
}
void Feature::knnMatch(const Mat& queryDescriptor Mat& trainDescriptor std::vector>& matches int k)
{
assert(k > 0);
assert(!queryDescriptor.empty());
assert(!trainDescriptor.empty());
assert(!m_matchType.empty());
matches.clear();
m_matcher = DescriptorMatcher::create(m_matchType);
m_matcher->add(std::vector(1 trainDescriptor));
m_matcher->train();
m_matcher->knnMatch(queryDescriptor matches k);
}
void Feature::saveKeypoints(const Mat& image const vector& keypoints const string& saveFileName)
{
assert(!saveFileName.empty());
Mat outImage;
cv::drawKeypoints(image keypoints outImage Scalar(2552550) DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
//
string saveKeypointsImgName = saveFileName + “_“ + m_detectType + “.jpg“;
imwrite(saveKeypointsImgName outImage);
}
void Feature::saveMatches(const Mat& queryImage
const vector& queryKeypoints
const Mat& trainImage
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3667 2017-11-23 16:38 LocalFeature.cpp
文件 1669 2017-11-23 16:37 LocalFeature.h
文件 0 2017-11-23 16:38 main.txt
----------- --------- ---------- ----- ----
5336 3
相关资源
- Opencv 各种特征点提取和匹配
- opencv调用摄像头并截图保存
- KinectV2 opencv qt 实现平面测量
- opencv_createsamples.exe opencv_traincascade.
- CvvImage类
- OpenCv视频采集
- OPENCV人脸检测程序可直接运行
- kinect深度图像去噪
- 用OpenCV实现Photoshop算法(九): 高反差
- 用OpenCV实现Photoshop算法_调整色相饱和
- opencv 人数统计
- Opencv学习视频
- opencv_world310.lib文件
- OpenCv2 轮廓提取源代码VS2008
- opencv2.4.4
- EMCV库函数
- 基于OPENCV的背景差法提取运动目标
- opencv视频教程地址
- 基于OpenCV实现的图片识别功能源码
- OpenCV基于分水岭图像分割算法
- 基于OpenCV的图像碎片拼接.pdf
- 图像的膨胀、腐蚀、以及开闭运算O
- opencv帧差法检测运动目标
- VS2013 + Opencv + libdmtx 识别 datamatrx ECC
- OpenCV代码链接库
- RGB到HSV空间直方图均衡化 opencv
- Qt VideoCapture图像采集
- 过滤掉源图像中亮度大于滑块位置的
- opencv实现ViBe算法source code
- QT+opencv图像几何变换,包括图像平移
评论
共有 条评论