如何在OpenCV C++中使用FeatureDetector?

发布于 2024-11-18 06:42:33 字数 311 浏览 5 评论 0原文

我使用的是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

丢了幸福的猪 2024-11-25 06:42:33

您正在声明一个指向 cv::Ptr 的指针——您确实应该只拥有 cv::Ptr。将您的代码更改为

#include "cv.h"
#include "highgui.h"

using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();

并且它应该可以工作。

You're declaring a pointer to a cv::Ptr -- you really should just have the cv::Ptr. Change your code to

#include "cv.h"
#include "highgui.h"

using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();

and it should work.

听风念你 2024-11-25 06:42:33

我认为您遇到安装问题,请尝试从此处重新安装: sourceforge.net/projects/opencvlibrary /files/opencv-win/2.2

另一个选项是你的预编译器已经有已定义__OPENCV_OLD_CV_H__
#include "cv.h" 时在 #include "cv.h" 之前取消定义它

尝试在输入
它应该自动包含 features2d。事实上cv.h包括以下内容:

#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/flann/flann.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/legacy/compat.hpp"

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:

#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/flann/flann.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/legacy/compat.hpp"
拥抱影子 2024-11-25 06:42:33

您需要 OpenCV 2.x 风格的 C++ 包含。见下文

#include "opencv2/features2d/features2d.hpp"
#include "cv.h"
#include "highgui.h"

using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();

You need the OpenCV 2.x style C++ include. See below

#include "opencv2/features2d/features2d.hpp"
#include "cv.h"
#include "highgui.h"

using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();
春花秋月 2024-11-25 06:42:33

您需要:(

#include <opencv2/nonfree/nonfree.hpp>

从这里:http://answers.opencv.org/问题/411/feature- detector-crash/

You need to:

#include <opencv2/nonfree/nonfree.hpp>

(from here: http://answers.opencv.org/question/411/feature-detector-crash/)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文