BUG - in cvUpdateTracks cvBLOB 0.10.4 when tracking with ROI

24 views
Skip to first unread message

neurodev

unread,
Nov 29, 2015, 10:20:40 AM11/29/15
to cvBlob
Hi all,

I wanted your help with a runtime error I hit when trying to track, using cvUpdateTracks, after defining a ROI in the images. 
It looks like a bug but your experience if much appreciated here.

After defining a ROI using 
cvSetImageROI

and then doing a tracking on a video with 30000 frames It is very likely that around 2000 frames or so in the video 
a runtime error happens in the clustering loop cvUpdateTracks which starts at Line 246 of cvtrack.cpp:
 // Clustering
      for (j=0; j<nTracks; j++) ....



at the point where it does   
// Update track
// cout << "Matching: track=" << track->id << ", blob=" << blob->label << endl;
track->label = blob->label; //FAILS due to null pointer issue.

I managed to circumvent the issue by initializing the structures blob and track to Null:
CvTrack *track = NULL;

 before these are set within the clustering subloops
and then check if these are null before updating :
  if  (track != NULL && blob != NULL )
          {

                  // Update track
                  cout << "Matching: track=" << track->id << ", blob=" << blob->label << endl;
                  track->label = blob->label;
                  track->centroid = blob->centroid;
                  track->minx = blob->minx;
                  track->miny = blob->miny;
                  track->maxx = blob->maxx;
                  track->maxy = blob->maxy;

                  if (track->inactive)
                    track->active = 0;
                  track->inactive = 0;
           }


But Its not clear to me why the issue arises, the original code conducts a search on line 261 to set the track struct:

 for (list<CvTrack*>::const_iterator it=tt.begin(); it!=tt.end(); ++it)
          {
            CvTrack *t = *it;
            unsigned int a = (t->maxx-t->minx)*(t->maxy-t->miny);
            if (a>area)
            {
              area = a;
              track = t;
            }
          }

But somehow it is assumed that this will not fail, and a t will always be set.
Initializing to null
CvTrack *track = NULL;
CvTrack *blob = NULL;
and checking if still null  after the search seems to fix the issue.

Thanks,
Kostas
Reply all
Reply to author
Forward
0 new messages