Tried to compile tracker from tutorial and got error "‘Tracker’ was not declared in this scope Ptr<Tracker> tracker = TrackerKCF::create();" [closed]

asked Oct 26 '18

viohh gravatar image

updated Oct 26 '18

berak gravatar image

Tried to compile tracker https://docs.opencv.org/3.1.0/d2/d0a/... and got error

"/home/vioh/tracker2/tracker2.cpp: In function ‘int main(int, char**)’:
/home/vioh/tracker2/tracker2.cpp:24:7: error: ‘Tracker’ was not declared in this scope
   Ptr<Tracker> tracker = TrackerKCF::create();
       ^
/home/vioh/tracker2/tracker2.cpp:24:14: error: template argument 1 is invalid
   Ptr<Tracker> tracker = TrackerKCF::create();
              ^
/home/vioh/tracker2/tracker2.cpp:24:26: error: ‘TrackerKCF’ has not been declared
   Ptr<Tracker> tracker = TrackerKCF::create();
                          ^
/home/vioh/tracker2/tracker2.cpp:35:10: error: base operand of ‘->’ is not a pointer
   tracker->init(frame,roi);
          ^
/home/vioh/tracker2/tracker2.cpp:45:12: error: base operand of ‘->’ is not a pointer
     tracker->update(frame,roi);
            ^
CMakeFiles/tracker2.dir/build.make:62: recipe execution error for goal «CMakeFiles/tracker2.dir/tracker2.cpp.o»
make[2]: *** [CMakeFiles/tracker2.dir/tracker2.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe execution error for goal «CMakeFiles/tracker2.dir/all»
make[1]: *** [CMakeFiles/tracker2.dir/all] Error 2
Makefile:83: recipe execution error for goal «all»
make: *** [all] Error 2

"

Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2018-10-27 05:34:41.314096

Comments

I have opencv 3.4.3 and installed all modules

viohh gravatar imageviohh (Oct 26 '18)edit

please use current docs, not outdated 3.1.0

you also need the opencv_contrib modules

berak gravatar imageberak (Oct 26 '18)edit

I have opencv contrib modules, but now I just can't include necessary hpp to the program.

viohh gravatar imageviohh (Oct 27 '18)edit

I just can't include necessary hpp to the program.

which means ?

which opencv version are you using, exactly ? (there is a version box in the opencv docs, make sure you use the correct tutorial code !)

berak gravatar imageberak (Oct 27 '18)edit

Sorry, I was using #include <opencv2/tracking.hpp> at first, but it couldn't find file, then I tried some other paths and it didn't work too, at the end I just used #include <opencv2/tracking.hpp> again and now its working, I don't know why. Thanks for help :)

viohh gravatar imageviohh (Oct 27 '18)edit

ok, "rubber duck debugging" ;)

berak gravatar imageberak (Oct 27 '18)edit
1

yea, exactly ;)

berak gravatar imageberak (Oct 29 '18)edit