Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在OpenCV C+中使用FeatureDetector+;?_C++_Opencv_Feature Detection - Fatal编程技术网

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

C++ 如何在OpenCV C+中使用FeatureDetector+;?,c++,opencv,feature-detection,C++,Opencv,Feature Detection,我正在使用VS2008,并按照安装指南安装了OpenCV 2.1。FeatureDetector/SurfFeatureDetector在文档中作为类列出,但它们被视为“语法错误:标识符'SurfFeatureDetector' 这几乎是我的全部代码 #include "cv.h" #include "highgui.h" Ptr<FeatureDetector> *detect = new SurfFeatureDetector(); #包括“cv.h” #包括“highgui

我正在使用VS2008,并按照安装指南安装了OpenCV 2.1。FeatureDetector/SurfFeatureDetector在文档中作为类列出,但它们被视为“语法错误:标识符'SurfFeatureDetector'

这几乎是我的全部代码

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

Ptr<FeatureDetector> *detect = new SurfFeatureDetector();
#包括“cv.h”
#包括“highgui.h”
Ptr*detect=新的SurfFeatureDetector();

我已经尝试了一系列随机组合来实现这一点。如何初始化featuredetector?

您正在声明一个指向cv::Ptr的指针--您真的应该只使用cv::Ptr。将代码更改为

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

using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();
#包括“cv.h”
#包括“highgui.h”
使用名称空间cv;
Ptr detect=新的SurfFeatureDetector();

它应该工作。

< p>你需要OpenCV 2。C++风格C++。见下文

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

using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();
#包括“opencv2/features2d/features2d.hpp”
#包括“cv.h”
#包括“highgui.h”
使用名称空间cv;
Ptr detect=新的SurfFeatureDetector();

我认为您有安装问题,请尝试从此处重新安装:

另一个选项是,您的预编译器已经定义了
\uuu OPENCV\u OLD\u CV\u H\uu
。 在
#包括“cv.h”

键入
#包括“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"
您需要:

#include <opencv2/nonfree/nonfree.hpp>
#包括

(从这里:)

那是什么类型的指针?确认,已编辑。应该是FeatureDetectorPtr类型是opencv自动指针,在使用结束时会删除自身。它仍然无法编译,似乎仍然无法找到FeatureDetector。有人说它在feature2d.hpp中,我在我的OpenCV2.1安装中找不到它,这可能是问题的原因吗?您是否有
使用命名空间cv代码中的某个地方?您必须包含该名称空间或手动声明
cv
名称空间。我以前使用过这些类,从来没有包含过“features2d.hpp”,但是在查看我的一些旧代码时,我也包含了可能需要的
#include
。您可能还需要再次检查您是否使用了OpenCV 2.1。features2d.hpp是否存在于/usr/local/include/opencv2/features2d中?您还可以使用
pkg config opencv--modversion
进行检查,具体取决于您安装opencv的方式。