【问题标题】:android opencv. feature detectors . implement detect安卓opencv。特征检测器。实施检测
【发布时间】:2013-07-02 22:32:50
【问题描述】:

我想用opencv 开发一个android 应用程序。 我有这个 C++ 代码

FastFeatureDetector detector(50);
detector.detect(mGr, v);

此代码运行正常。

现在我想使用不同的检测器:

OrbFeatureDetector detector;
detector.detect(mGr, v);

但我收到以下错误:

The type 'cv::ORB' must implement the inherited pure virtual method 'cv::FeatureDetector::detectImpl'

是什么原因?

【问题讨论】:

    标签: android c++ opencv android-ndk feature-detection


    【解决方案1】:

    有一个基础类,它是FeatureDetector(链接是最新的文档)。 FeatureDetector 有一个纯虚方法detectImpl。至少在您的 OpenCV 版本中。从 FeatureDetector 派生的所有类(子类)都必须实现该方法。显然,FastFeatureDetector 实现了该方法,但 OrbFeatureDetector 没有。

    我在documentation看到有很多儿童班: 除了FastFeatureDetector,还有thisthisthisthisthisthis

    我还找到了cv::ORB,但没有找到 OrbFeatureDetector。有一些“痕迹”here(当时是“候选”),但我想知道您使用的是哪个 opencv 版本...您是否尝试包含文件orb.h

    无论如何,我建议,如果您还没有,请将您的 opencv 版本更新到最新版本,并使用cv::ORB,如下所述:https://stackoverflow.com/a/12202175/2436175

    【讨论】:

      【解决方案2】:

      code of the feature2d module header 中可以看出,OrbFeatureDetector 类型是 cv::ORB 类的同义词:

      typedef ORB OrbFeatureDetector;
      

      深入研究 cv::ORB 类的实现,我发现它没有虚拟方法,因此您获得的错误消息不应该发生,但如果您尝试例如声明一个 cv 类型的变量,它就会发生::特征检测器:

      cv::FeatureDetector detector;
      

      当您希望通过将检测器的类型设置为超类的类型来轻松切换检测器实现时,通常会这样做。在这种情况下,要克服这个问题,只需定义一个指向 cv::FeatureDetector 的指针,如this other stackoverflow question 中所述:

      FeatureDetector* detector;
      

      您还可以使用 OpenCv 的智能指针:

      cv::Ptr<cv::FeatureDetector> detector;
      

      【讨论】:

        猜你喜欢
        • 2017-07-25
        • 1970-01-01
        • 1970-01-01
        • 2023-03-21
        • 2011-07-11
        • 2018-04-21
        • 2016-05-19
        • 1970-01-01
        • 2013-09-14
        相关资源
        最近更新 更多