opencv 中sift 的使用
2013-09-16 22:59
459 查看
opencv 中Algorithm 封装了很多算法,实验过程中,发现sift,surf等在nonfree模块中的代码,需要initModule_nonfree();来注册算法,不然create 会返回空指针,这在opencv文档中有介绍。
Ptr<Feature2D> sift = Algorithm::create<Feature2D>("Feature2D.FAST");
对于上面这样的代码虽然可以通过编译,但是没有意义,因为Feature2D 仅有的操作是detect and compute,而Fast 仅仅实现了detect,因此运行时会出错,但是不知道为什么opencv 让Feature2D.FAST 继承了 Feature2D.
实际上应该这样用:
Ptr<FeatureDetector> Fast_detect = Algorithm::create<FeatureDetector>("Feature2D.FAST");
一些测试代码:
#include <opencv2/opencv.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/nonfree/features2d.hpp>
using namespace std;
using namespace cv;
void main()
{
Mat image = imread("f:\\fruits.jpg");
Mat descriptors;
vector<KeyPoint> keypoints;
initModule_nonfree();
Ptr<Feature2D> sift = Algorithm::create<Feature2D>("Feature2D.SIFT");
(*sift)(image, noArray(), keypoints, descriptors);
Ptr<FeatureDetector> Fast_detect = Algorithm::create<FeatureDetector>("Feat ure2D.FAST");
//Ptr<DescriptorExtractor> Fast_extract = Algorithm::create<Feature2D>("Featur e2D.FAST");
//Fast_detect->detect(image,keypoints);
//Fast_extract->compute(img,kepoints,descriptors);
drawKeypoints(image, keypoints, image, Scalar(255,0,0),4);
imshow("test", image);
waitKey();
}
Ptr<Feature2D> sift = Algorithm::create<Feature2D>("Feature2D.FAST");
对于上面这样的代码虽然可以通过编译,但是没有意义,因为Feature2D 仅有的操作是detect and compute,而Fast 仅仅实现了detect,因此运行时会出错,但是不知道为什么opencv 让Feature2D.FAST 继承了 Feature2D.
实际上应该这样用:
Ptr<FeatureDetector> Fast_detect = Algorithm::create<FeatureDetector>("Feature2D.FAST");
一些测试代码:
#include <opencv2/opencv.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/nonfree/features2d.hpp>
using namespace std;
using namespace cv;
void main()
{
Mat image = imread("f:\\fruits.jpg");
Mat descriptors;
vector<KeyPoint> keypoints;
initModule_nonfree();
Ptr<Feature2D> sift = Algorithm::create<Feature2D>("Feature2D.SIFT");
(*sift)(image, noArray(), keypoints, descriptors);
Ptr<FeatureDetector> Fast_detect = Algorithm::create<FeatureDetector>("Feat ure2D.FAST");
//Ptr<DescriptorExtractor> Fast_extract = Algorithm::create<Feature2D>("Featur e2D.FAST");
//Fast_detect->detect(image,keypoints);
//Fast_extract->compute(img,kepoints,descriptors);
drawKeypoints(image, keypoints, image, Scalar(255,0,0),4);
imshow("test", image);
waitKey();
}
相关文章推荐
- 在OpenCV3.1.0中使用SIFT,SURF算法
- 使用RANSAC提纯SIFT和SURF特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)
- opencv SURF、SIFT的使用
- OpenCV中SUFR、SIFT无法使用的原因及解决办法
- OpenCV2.4.9新版本使用问题---sift,surf无法使用
- opencv中SIFT匹配对于误匹配点RANSAC算法接口的使用
- Opencv 2.4.1中的SIFT函数使用问题
- 使用Opencv2.4.9进行SIFT特征点提取和匹配
- python3.5 opencv3.1 不能使用sift, surf。
- OPENCV下SIFT算法使用方法笔记
- OpenCV2.4.9新版本使用问题---sift,surf无法使用
- OPENCV下SIFT算法使用方法笔记
- opencv下SIFT使用
- opencv2.4.6版本下使用sift等特征
- 基于Opencv的SIFT代码,使用FLANN匹配
- 使用OPENCV自带的sift提取特征
- OpenCV3.1 xfeatures2d::SIFT 使用
- OpenCV3.1 xfeatures2d::SIFT 使用
- OpenCV3如何使用SIFT和SURF Where did SIFT and SURF go in OpenCV 3?
- 使用OPENCV自带的sift提取特征