错误:'create'不是'cv :: Tracker'的成员

fft*_*tyy 3 c++ opencv tracking

官方教程我在标题中的错误.应该是什么原因?

Ptr<Tracker> tracker = Tracker::create( "KCF" );
Run Code Online (Sandbox Code Playgroud)

这里是tracking.hpp的一部分:

    @endcode
    of course, you can also add any additional methods of your choice. It should be pointed out,
    however, that it is not expected to have a constructor declared, as creation should be done via
    the corresponding createTracker() method.
   In src/tracker.cpp file add BOILERPLATE_CODE(name,classname) line to the body of
    Tracker::create() method you will find there, like :
@code
        Ptr<Tracker> Tracker::create( const String& trackerType )
        {
          BOILERPLATE_CODE("BOOSTING",TrackerBoosting);
          BOILERPLATE_CODE("MIL",TrackerMIL);
          return Ptr<Tracker>();
        }
@endcode
-   Finally, you should implement the function with signature :
@code
        Ptr<classname> classname::createTracker(const classname::Params &parameters){
            ...
        }
@endcode
Run Code Online (Sandbox Code Playgroud)

我正在使用3.2.0版本.

the*_*rge 9

您粘贴的代码tracking.hpp不是实际代码,它只是示例代码,是文档的一部分.跟踪头文件中唯一相关的代码是:

#include <opencv2/tracking/tracker.hpp>
#include <opencv2/tracking/tldDataset.hpp>
Run Code Online (Sandbox Code Playgroud)

因此,要查看您实际导入的内容,您需要查看该tracking/tracker.hpp文件(此处).

如果你这样做,你会发现类声明中没有static create方法Tracker.该提交实际上删除了该方法.所以,基本上,你是对的:删除方法后教程没有更新.您应该将您的问题报告给opencv团队.

话虽这么说,为了使教程工作,你可能需要替换那些没有编译的行:

Ptr<TrackerKCF> tracker = TrackerKCF::create();
Run Code Online (Sandbox Code Playgroud)

这应该够了吧.