opencv 中sift 的使用
来源:互联网 发布:正大软件学校 编辑:程序博客网 时间:2024/05/29 07:53
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();
}
- opencv 中sift 的使用
- OpenCV中SIFT的实现
- opencv SURF、SIFT的使用
- OpenCV中SUFR、SIFT无法使用的原因及解决办法
- Java opencv中sift的实现
- opencv中sift算法
- opencv中sift算法
- opencv下SIFT使用
- opencv中关于sift匹配
- 基于Opencv的SIFT代码,使用FLANN匹配
- 使用OPENCV自带的sift提取特征
- 使用OPENCV自带的sift提取特征
- sift的opencv简易实现
- 使用Spark批量上传图片到HBase中并同时使用OpenCV提取SIFT特征值
- SIFT:第一步使用OpenCV构建DOG金字塔
- 基于OpenCV的SIFT算法的实现
- Opencv SIFT需要注意的地方
- opencv 提取SIFT特征的程序
- Java学习总结之线程
- 空指针异常
- XMPP -- XML节
- 一个百度程序员的创业故事
- 00-iOS开发经典语录
- opencv 中sift 的使用
- DB2创建临时表时的错误
- HDU 1588 Gauss Fibonacci(矩阵快速幂+二分求等比数列和)
- 模拟 mfc 类型识别
- 用pig实现的矩阵乘
- centos 安装postgresql
- locale
- Tomcat7 Debug run in ecplise
- Yii笔记