Assertion Fail on Calling chamerMatching(img, tpl, ...) if the input image does not have detectable edges (Patch #1655)


Added by Changbo Zhou about 13 years ago. Updated almost 13 years ago.


Status:Done Start date:2012-03-07
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:legacy, contrib
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The following code in "opencv / modules / contrib / src / chamfermatching.cpp" has an risk of leaving annotate_img uninitialized, causing Assertion Fail in following stages:

 1for (int y=0;y<h;++y) {
 2    for (int x=0;x<w;++x) {
 3
 4        unsigned char edge_val = edges_img.at<uchar>(y,x);
 5        if ( (edge_val!=0) ) {
 6            q.push(std::make_pair(x,y));
 7            dist_img.at<float>(y,x)= 0;
 8
 9            if (&annotate_img!=NULL) {
10                annotate_img.at<Vec2i>(y,x)[0]=x;
11                annotate_img.at<Vec2i>(y,x)[1]=y;
12            }
13        }
14        else {
15            dist_img.at<float>(y,x)=-1;
16        }
17    }
18}

The code should be like this:

 1for (int y=0;y<h;++y) {
 2    for (int x=0;x<w;++x) {
 3        // initialize
 4        if (&annotate_img!=NULL) {
 5            annotate_img.at<Vec2i>(y,x)[0]=x;
 6            annotate_img.at<Vec2i>(y,x)[1]=y;
 7        }
 8
 9        unsigned char edge_val = edges_img.at<uchar>(y,x);
10        if ( (edge_val!=0) ) {
11            q.push(make_pair(x,y));
12            dist_img.at<float>(y,x)= 0;
13        }
14        else {
15            dist_img.at<float>(y,x)=-1;
16        }
17    }
18}

I am testing on :
Windows XP
Visual Studio Professional 2008
OpenCV 2.3.1


Associated revisions

Revision e778007d
Added by Vadim Pisarevsky almost 13 years ago

applied patch from #1655 (thanks to Changbo Zhou!)

Revision 66e5be2d
Added by Andrey Pavlenko over 11 years ago

Merge pull request #1655 from pengx17:2.4_opt_superres_ocl

History

Updated by Alexander Shishkov almost 13 years ago

  • Tracker changed from Bug to Patch
  • Target version deleted ()
  • Description changed from The following code in "opencv / modules / contrib / src / chamfermatchin... to The following code in "opencv / modules / contrib / src / chamfermatchin... More

Updated by Alexander Shishkov almost 13 years ago

  • Category set to legacy, contrib

Updated by Alexander Shishkov almost 13 years ago

  • Priority changed from Normal to High

Updated by Vadim Pisarevsky almost 13 years ago

thanks! fixed in r7624

  • Status changed from Open to Done
  • Assignee set to Vadim Pisarevsky

Updated by Alexander Shishkov almost 13 years ago

  • Target version set to 2.4.0

Also available in: Atom PDF