Run-Time Check Failure

33 views
Skip to first unread message

Hugo Álvarez García

unread,
Oct 22, 2012, 4:30:08 AM10/22/12
to cvb...@googlegroups.com
Hi folks,
I'm writing a simple tracking program in visual studio 2010 and have this error.

My program works fine --it just read an image from a video sequence in a loop, classify blobs, and track them--, but when it loads the image number 301, in the middle of the video sequence, while calling the function:

cvUpdateTracks(blobs, trks, 10.0, 10);

I got this error:
Run-Time Check Failure #3 - The variable 'track' is being used without being initialized.

I have no variable called 'track' in my code... do you have any idea what could be the problem?
Thank you!

Here you have some lines of my code:

                        unsigned int result = cvLabel(&img_etiq, labelImg, blobs);
                        threshold(matblobs, matblobs, 0.4*maxval8, 255, CV_THRESH_BINARY);
IplImage img_etiq=matblobs;

cvSetImageROI(&img_etiq, cvRect(0, 0, 320, 240));
IplImage *labelImg = cvCreateImage(cvGetSize(&img_etiq), IPL_DEPTH_LABEL, 1);
CvBlobs blobs;
        unsigned int result = cvLabel(&img_etiq, labelImg, blobs);

                        [...]

cvFilterByArea(blobs, 4, 1000);
ERROR->   cvUpdateTracks(blobs, trks, 10.0, 10);

Carlos Martins

unread,
Oct 22, 2012, 5:16:18 AM10/22/12
to cvb...@googlegroups.com
Just for debug purposes, have you tried calling the loop with the same image (for instance, the 1st frame) 301 times repeatedly?
(just to check it isn't something image related)

As for the track variable, it is the one used internally by the cvUpdateTracks function, referring to your "trks" parameter.

My guess is that your code sometimes isn't initializing it in some particular case (maybe when there are no blobs?).

Hugo Álvarez García

unread,
Oct 22, 2012, 5:51:14 AM10/22/12
to cvb...@googlegroups.com
I was using a precompiled library... Now I have included de cvBlob source code to debug this problem.
With the same frame (for example the first one) it doesn't happen..

I found the error is in this line of cvtrack.cpp (line 292, cvUpdateTracks function):

          // Update track
          //cout << "Matching: track=" << track->id << ", blob=" << blob->label << endl;
ERROR->  track->label = blob->label;

I don't understand this error, cause the variable track already exists..  It might be related with Visual Studio??

Thank you Carlos!
cvtrack.cpp

Carlos Martins

unread,
Oct 22, 2012, 6:38:48 AM10/22/12
to cvb...@googlegroups.com
Most likely it is a special case of that specific frame. Try processing it as if it were the first or sencond frame, and it should give you the error immediately.

And then try to track down why the "track" variable is not getting any results.

(I've also had my fair share of bugs and issues with small 1-3 pixel sized blobs and several perimeter related functions.)

Hugo Álvarez García

unread,
Oct 22, 2012, 7:01:09 AM10/22/12
to cvb...@googlegroups.com
You gave me a good clue, a small (4 or 5 pixels) blob appeared on scene in that frame... I put a bigger size blob filter and now it works.
I don't understand yet where was the problem, but I will be carefull with that small blobs from now on.

Gracias! ;)

2012/10/22 Carlos Martins <carlosm...@gmail.com>



--
Hugo Álvarez García
Reply all
Reply to author
Forward
0 new messages