如何在OpenCV C++中使用FeatureDetector?
我使用的是 VS 2008,按照安装指南安装了 OpenCV 2.1。 FeatureDetector/SurfFeatureDetector 在文档中被列为类,但它们被视为“语法错误:标识符'SurfFeatureDetector”
这几乎是我的代码的全部。
#include "cv.h"
#include "highgui.h"
Ptr<FeatureDetector> *detect = new SurfFeatureDetector();
我尝试了一些随机组合来使其发挥作用。如何初始化特征检测器?
I am using VS 2008 with OpenCV 2.1 installed as per the installation guide. FeatureDetector/SurfFeatureDetector are listed as classes in the documentation, but they are considered "syntax error : identifier 'SurfFeatureDetector"
This is pretty much the entirety of my code.
#include "cv.h"
#include "highgui.h"
Ptr<FeatureDetector> *detect = new SurfFeatureDetector();
I've tried a bunch of random combinations to get this to work. How can I initialize a featuredetector?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您正在声明一个指向 cv::Ptr 的指针——您确实应该只拥有 cv::Ptr。将您的代码更改为
并且它应该可以工作。
You're declaring a pointer to a cv::Ptr -- you really should just have the cv::Ptr. Change your code to
and it should work.
我认为您遇到安装问题,请尝试从此处重新安装: sourceforge.net/projects/opencvlibrary /files/opencv-win/2.2
另一个选项是你的预编译器已经有已定义
__OPENCV_OLD_CV_H__
。#include "cv.h"
时在#include "cv.h"
之前取消定义它尝试在输入
它应该自动包含 features2d。事实上cv.h包括以下内容:
I think you have installation problem, try resinstalling from here: sourceforge.net/projects/opencvlibrary/files/opencv-win/2.2
anther other option is that your precompiler already has
__OPENCV_OLD_CV_H__
defined.Try undefining it before
#include "cv.h"
When you type
#include "cv.h"
It automatically should include featurs2d. in fact cv.h includes the following:
您需要 OpenCV 2.x 风格的 C++ 包含。见下文
You need the OpenCV 2.x style C++ include. See below
您需要:(
从这里:http://answers.opencv.org/问题/411/feature- detector-crash/)
You need to:
(from here: http://answers.opencv.org/question/411/feature-detector-crash/)