chamerMatching giving error "Debug Assertion failed!"
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.