Error in Using TrackerKCF in Ubuntu /Linux

asked 2017-02-12 12:11:56 -0500

ibrahim.kaa gravatar image

I have built successfully OpenCV 3.2 with the extra modules contribution successfully on Ubuntu. However, I'm having an error when building a code that uses (TrackerKCF::MODE), although this code was compiled successfully on Windows. Is there some syntax or includes I need to change or add?

Error Message:
(error: ‘cv::TrackerKCF::MODE’ is not a class or namespace param.desc_pca = TrackerKCF::MODE::CN | TrackerKCF::MODE::GRAY; )

Include List:

#include <iostream>  
#include <string> 
#include "cv.h"  
#include "highgui.h"  
#include <stdio.h>
#include <opencv2/opencv.hpp> 
#include <opencv2/video/video.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <cstdio>
#include <fstream>
#include <sstream>
#include<math.h>
#include<time.h>
edit retag flag offensive close merge delete

Comments

For opencv you need only

#include <opencv2/opencv.hpp> 
#include <opencv2/tracking.hpp>
#include <cstdio>
#include <fstream>
#include <sstream>
#include<math.h>
#include<time.h>
#include <iostream>  
#include <string> 
#include <stdio.h>

Now without code it is difficult to test. Difference could be that there is an error in tracker opencv_contrib module for ubuntu.

LBerger gravatar imageLBerger ( 2017-02-12 12:56:14 -0500 )edit

Thanks. How could I determine or check that?

ibrahim.kaa gravatar imageibrahim.kaa ( 2017-02-12 13:06:17 -0500 )edit

I don't know linux enough to help you. I think if there is a problem it is in CMake. tracking module needs all this module too opencv_imgproc opencv_core opencv_video opencv_highgui opencv_dnn opencv_plot.

Have you build opencv_contrib ?

Can you find libopencv_tracking.so (check library name)?

LBerger gravatar imageLBerger ( 2017-02-12 13:14:46 -0500 )edit

Yes they all exist actually

ibrahim.kaa gravatar imageibrahim.kaa ( 2017-02-12 13:48:17 -0500 )edit
LBerger gravatar imageLBerger ( 2017-02-12 13:55:18 -0500 )edit

Yes I can. I expect something like a syntax difference when using TrackerKCF::Mode, or in including the required libraries for it in Ubuntu?

ibrahim.kaa gravatar imageibrahim.kaa ( 2017-02-12 14:11:10 -0500 )edit

It is a compilation error. it cannot be a problem with link libraries. Have you got two versions of opencv on your computer?

you can try something like this if it is possible rename kcf.cpp example. Copy your source file in opencv_contrib/modules/tracking/samples rename it kcf.cpp and build this "new sample"

LBerger gravatar imageLBerger ( 2017-02-12 14:21:11 -0500 )edit

Could you include the line of code + one or two lines above and below that's causing the error message?

Tetragramm gravatar imageTetragramm ( 2017-02-12 16:26:00 -0500 )edit

@LBerger, sorry I think I did not give the right answer. When I run opencv_contrib/modules/tracking/samples/kcf.cpp in this directory I get the following error: "error while loading shared libraries: libopencv_tracking.so.3.2: cannot open shared object file: No such file or directory " And I actually have more than one opencv version, but I'm only interested in the latest 3.2

ibrahim.kaa gravatar imageibrahim.kaa ( 2017-02-14 13:02:22 -0500 )edit

I managed to fix the libopencv_tracking.so error from this link: http://stackoverflow.com/questions/19164343/opencv-libopencv-core-so-2-4-cannot-open-shared-object-file-no-such-file-or (http://stackoverflow.com/questions/19...)

However, now kcf.cpp compiles and I have replaced the file with the file I want to run as you have suggested, but I still get the original error here:

error: ‘cv::TrackerKCF::MODE’ is not a class or namespace param.desc_pca = TrackerKCF::MODE::CN | TrackerKCF::MODE::GRAY;

========================================== Thanks much for help so far

ibrahim.kaa gravatar imageibrahim.kaa ( 2017-02-14 14:35:01 -0500 )edit

Dear @Tetragramm , Following are lines of the code around the error:

        Rect a;
        a.x = a.y = a.height = a.width = 0;
        group_whenOcclusion.insert(group_whenOcclusion.end(), a);
        TrackerKCF::Params param;
        param.desc_pca = TrackerKCF::MODE::CN | TrackerKCF::MODE::GRAY;
        Ptr<TrackerKCF> tracker = TrackerKCF::createTracker(param);

        //Ptr<Tracker> tracker = Tracker::create("KCF");
        tracker_vector.insert(tracker_vector.end(), tracker);

        vector<Rect> rect_save;

Thanks much

ibrahim.kaa gravatar imageibrahim.kaa ( 2017-02-14 14:40:11 -0500 )edit