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

asked 2018-10-25 19:02:01 -0600

viohh gravatar image

updated 2018-10-25 23:01:50 -0600

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

"

edit retag flag offensive reopen merge delete

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 ( 2018-10-25 19:13:13 -0600 )edit

please use current docs, not outdated 3.1.0

you also need the opencv_contrib modules

berak gravatar imageberak ( 2018-10-25 23:02:53 -0600 )edit

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

viohh gravatar imageviohh ( 2018-10-27 05:13:15 -0600 )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 ( 2018-10-27 05:20:54 -0600 )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 ( 2018-10-27 05:28:48 -0600 )edit

ok, "rubber duck debugging" ;)

berak gravatar imageberak ( 2018-10-27 05:33:57 -0600 )edit
1
LBerger gravatar imageLBerger ( 2018-10-29 06:54:48 -0600 )edit

yea, exactly ;)

berak gravatar imageberak ( 2018-10-29 07:00:59 -0600 )edit