Creating my own tracker using tracker module in opencv-contrib

asked 2017-08-19 12:12:15 -0500

babahooja gravatar image

updated 2017-08-19 13:47:28 -0500

I am trying to create my own tracker using opencv-contrib tracker module. For that I am first trying to replicate the MIL Tracker provided in the contrib. I added my tracker class to the tracking/opencv2/tracker.hpp file. Then, I build the files. I copied the files trackerMIL.cpp, trackerMILModel.hpp, trackerMILModel.cpp and edited the files to suit my own tracker name. I am using the same target estimation method used in MIL. I get the error:

error: (-1) The model is not initialized in function init. How should I resolve this error? The error originates from here (tracker.cpp)

  sampler = Ptr<TrackerSampler>( new TrackerSampler() );
  featureSet = Ptr<TrackerFeatureSet>( new TrackerFeatureSet() );
  model = Ptr<TrackerModel>();

  bool initTracker = initImpl( image.getMat(), boundingBox );

  //check if the model component is initialized
  if( model == 0 )
    CV_Error( -1, "The model is not initialized" );
    return false;
edit retag flag offensive close merge delete


Do I need to build the specific model files before using it?

babahooja gravatar imagebabahooja ( 2017-08-19 14:53:21 -0500 )edit
sturkmen gravatar imagesturkmen ( 2017-08-19 15:21:47 -0500 )edit

@sturkmen yes I did! I believe the documentation is a bit old wrt the code in the contrib, because it mentions the macro 'BOILERPLATE_CODE' which is absent in the code.

babahooja gravatar imagebabahooja ( 2017-08-19 15:27:46 -0500 )edit

do you have a tracker code or you are trying to implement something

sturkmen gravatar imagesturkmen ( 2017-08-19 16:04:36 -0500 )edit

i have added before some trackers on my local (yes i used BOILERPLATE_CODE when i did. some changes have made on the api)

sturkmen gravatar imagesturkmen ( 2017-08-19 16:07:13 -0500 )edit

if you explain what you want to do maybe i can help

sturkmen gravatar imagesturkmen ( 2017-08-19 16:08:37 -0500 )edit

I am trying to make some changes in MIL's original implementation. I am unable to understand where to put these changes. I don't want to hamper the original implementation of MIL. I had a look at the link above on customizing tracker, but I can't understand how can I add more methods to the original MIL model.

babahooja gravatar imagebabahooja ( 2017-08-19 17:10:44 -0500 )edit

I tried duplicating all the files in tracking/src/ with my own model name (and with changes in the code wrt to model name MIL --> newMIL ). I also added my tracker class in tracker.hpp. Then I built the files using cmake, followed by make and make install, but still my code shows error as mentioned in the question.

babahooja gravatar imagebabahooja ( 2017-08-19 17:13:38 -0500 )edit

Basically, I want to make a new tracker with the exact same code as that of TrackerMIL and then build upon it.

babahooja gravatar imagebabahooja ( 2017-08-19 17:17:34 -0500 )edit

see this. i cloned MIL to MIL2 just to give an idea

sturkmen gravatar imagesturkmen ( 2017-08-20 03:02:11 -0500 )edit