OpenCV 4.5.3, C++, VS 2017, MFC, Win10

Using the example code in the OpenCV docs Using MultiTracker.

// create the tracker
legacy::MultiTracker trackers;
// initialize the tracker
 std::vector<Ptr<legacy::Tracker> > algorithms;

The docs have the next key line as

I don’t know where that createTrackerByName_legacy came from but I figure I could just use a Tracker.create() in its place like this
Ptr<legacy::Tracker> TBtracker = TrackerKCF::create();
But when I go to the push_back line
I get the VS2017 compile error

error C2664 > noexcept': cannot convert argument 1 from 'cv::Ptr<cv::tracking::TrackerKCF>' to 'std::nullptr_t'

> algorighms is a vector of Ptr<legacy::Tracker> 
> and TBtracker is a Ptr<legacy::Tracker> 
> and I am trying to push a Ptr<legacy::Tracker>  into a vector of Ptr<legacy::Tracker>

Where would anyone say that I am going wrong that I am getting this compile error?


I think I have figured it out although I have only compiled and nave not continued beyond that point yet.

My fix was to leave off the legacy:: in everything other than MulTracker so I have

legacy::MultiTracker trackers;
std::vector<Ptr<Tracker> > algorithms;
Ptr<Tracker> TBtracker = TrackerKCF::create();

Now it compiles.

PS…except when I add the final line
trackers.add(algorithms, frame, objects);
The compile error now is
cannot convert argument 1 from 'std::vector<cv::Ptr<cv::Tracker>,std::allocator<_Ty>>' to 'cv::Ptr<cv::legacy::tracking::Tracker>'

So it goes…


OK…I got it to compile.

In \opencv_contrib-4.x\modules\tracking\samples\multitracker.cpp I found the code that is used in the OCV 4.5.3 docs on the Using MultiTracker page. It also used the createTrackerByName_legacy and I saw at the top that they did an
#include "samples_utility.hpp"
Looking at that I see that the tracker was a

Ptr<cv::legacy::Tracker> TBtracker; 
TBtracker = legacy::TrackerKCF::create();

Somewhere I had gotten

Ptrcv::legacy::tracking::Tracker TBtracker;
which compiled but then didn’t work with algorithms.push_back.

and even
TrackerKCF::create(); instead of legacy::TrackerKCF::create()

So now it compiles…I find out soon enough if it runs…