Ask Your Question
0

chamerMatching giving error "Debug Assertion failed!"

asked 2014-05-26 09:50:41 -0600

Ram Kumar gravatar image

updated 2014-05-26 09:51:53 -0600

Hi All,

When I am trying to use chamerMatching getting below error. Please let me know any solutions for this.

Debug Assertion failed! \VC\include\Vector Line 238 Expression:Vector iterators incompatible

Below is the code I used.

int main( int argc, const char** argv ) { string image = "d:\1.jpg"; string templ = "d:\2.jpg";

Mat img = imread(image, CV_LOAD_IMAGE_GRAYSCALE );
Mat tpl = imread(templ, CV_LOAD_IMAGE_GRAYSCALE );
Mat cimg;

if (img.empty() || tpl.empty())
{
    cout << "Could not read image file " << image << " or " << templ << "." << endl;
    return -1;
}


// if the image and the template are not edge maps but normal grayscale images,
// you might want to uncomment the lines below to produce the maps. You can also
// run Sobel instead of Canny.

 Canny(img, img, 5, 50, 3);
 Canny(tpl, tpl, 5, 50, 3);



std::vector<std::vector<cv::Point>> results;

std::vector<float> costs; int best = chamerMatching( img, tpl, results, costs ); if( best < 0 ) { cout << "matching not found" << endl; return -1; }

size_t i, n = results[best].size();
for( i = 0; i < n; i++ )
{
    Point pt = results[best][i];
    if( pt.inside(Rect(0, 0, cimg.cols, cimg.rows)) )
       cimg.at<Vec3b>(pt) = Vec3b(0, 255, 0);
}

imshow("result", cimg);

waitKey(0);

return 0;

}

Thanks, RamKumar.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-20 08:13:34 -0600

unixer gravatar image

hit this issue with opencv 2.4.9

edit flag offensive delete link more

Comments

hmm, maybe use cimg.at<Vec3b>(pt.y, pt.x) = ... , but apart from that I have no other ideas

Guanta gravatar imageGuanta ( 2014-07-21 16:16:04 -0600 )edit

It doesn't work. I am afraid the problem is in "int best = chamerMatching( img, tpl, results, costs )" as it never returns and outputs the error. Please see http://ngoding.co/read/2014/07/debug-assertion-failed-vcincludevector-vector-iterator-offset-out-of-range-in-chamfermatching-opencv/ This is a similar error. Do you think the solution (comment delete templates[i]) works for this error as well? I don't have an environment to debug this error.

unixer gravatar imageunixer ( 2014-07-22 00:00:29 -0600 )edit

Hm, probably not, the error indicates some wrong iterator not a double free, but you could of course try it and see what happens, sry that I can't help you further, it seems like a real bug and you should report it at http://code.opencv.org/issues/ . However note that the main developers often do not have the time to fix these bugs, so the best is if you would figure it out and make then a pull request, s. http://code.opencv.org/projects/opencv/wiki#Issue-Tracking

Guanta gravatar imageGuanta ( 2014-07-22 02:13:56 -0600 )edit

Thanks Guanta. I think I should setup an compile environment to try this, even fix it. Are you a developer of opencv? Can I add you as friend on Gtalk or Skype or something else? I am a newbie in computer vision area. I definitely need your help.

unixer gravatar imageunixer ( 2014-07-22 02:28:08 -0600 )edit

Sry, but I am not a developer of OpenCV and also don't use gtalk or skype on a regular basis (I have a skype account but actually I don't use it at all), but there is an opencv - irc channel at freenode #opencv, guess that would be the best way to get immediate help. Othwerwise just open here a new question and s.o. will hopefully answer it.

Guanta gravatar imageGuanta ( 2014-07-22 06:48:35 -0600 )edit

Thanks Guanta. I am in the chat room. My id is unixer. Are you often there?

unixer gravatar imageunixer ( 2014-07-23 00:59:58 -0600 )edit

No, not really, but I hope there are persons who can help you.

Guanta gravatar imageGuanta ( 2014-07-23 04:02:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-26 09:50:41 -0600

Seen: 889 times

Last updated: Jul 20 '14