c++ - cv::gpu::SURF_GPU 使用期间的问题: ‘KeyPoint’ 未在此范围内声明

标签 c++ opencv

这里尝试使用 opencv 的类:SURF_GPU。

testSURFGPU.cpp:

#include <opencv2/nonfree/gpu.hpp>

int main(int argc, char* argv[])
{
    cv::gpu::SURF_GPU surf;

    return 0;
}

控制台命令:

g++ test_surf.cpp -o test `pkg-config --cflags --libs opencv`

以下是我编译时的错误信息:

控制台响应:

    /usr/local/include/opencv2/nonfree/gpu.hpp:75:44: error: ‘KeyPoint’ was not declared in this scope
         void uploadKeypoints(const std::vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
                                                ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:75:52: error: template argument 1 is invalid
         void uploadKeypoints(const std::vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
                                                        ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:75:52: error: template argument 2 is invalid
    /usr/local/include/opencv2/nonfree/gpu.hpp:77:68: error: ‘KeyPoint’ was not declared in this scope
         void downloadKeypoints(const GpuMat& keypointsGPU, std::vector<KeyPoint>& keypoints);
                                                                        ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:77:76: error: template argument 1 is invalid
         void downloadKeypoints(const GpuMat& keypointsGPU, std::vector<KeyPoint>& keypoints);
                                                                                ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:77:76: error: template argument 2 is invalid
    /usr/local/include/opencv2/nonfree/gpu.hpp:98:72: error: ‘KeyPoint’ was not declared in this scope
         void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
                                                                            ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:98:80: error: template argument 1 is invalid
         void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
                                                                                    ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:98:80: error: template argument 2 is invalid
    /usr/local/include/opencv2/nonfree/gpu.hpp:99:72: error: ‘KeyPoint’ was not declared in this scope
         void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
                                                                            ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:99:80: error: template argument 1 is invalid
         void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
                                                                                    ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:99:80: error: template argument 2 is invalid
    /usr/local/include/opencv2/nonfree/gpu.hpp:102:72: error: ‘KeyPoint’ was not declared in this scope
         void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
                                                                            ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:102:80: error: template argument 1 is invalid
         void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
                                                                                    ^
    /usr/local/include/opencv2/nonfree/gpu.hpp:102:80: error: template argument 2 is invalid

我做错了什么? OpenCV 的文件 (gpu.hpp) 如何无法识别 Opencv 的对象 (KeyPoint)? 任何帮助将不胜感激。

谢谢。

设置:Ubuntu 14.04、OpenCV 2.4.11

最佳答案

您缺少 cv::KeyPoint 定义的包含。

尝试添加

#include <opencv2/features2d/features2d.hpp>

到您的演示代码。

关于c++ - cv::gpu::SURF_GPU 使用期间的问题: ‘KeyPoint’ 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34312168/

相关文章:

C++:如何解决具有多个多态输入的方法调用?

c++ - OpenCV - 来自相机的实时反馈不流畅

python - 为什么 find_objects 会给出一堆无,然后是整个图像的范围?

opencv - ISO调整和亮度公式的代码实现

c++ - winpcap抓包的单位是什么,二层帧还是三层包?

c++ - 从 Linux 构建 Windows 应用程序时,如何使用 CMake 获取它的依赖项?

python - Python 中 OpenCV checkVector 的断言错误

c++ - 从image.ppm c++创建视频

c++ - OpenAL - 确定最大来源

c++ - 最小(最大)处理器状态 API,C++