Ask Your Question

Revision history [back]

debug assertion failed vc\include\vector vector iterator + offset out of range in chamferMatching Opencv

am stuck with the problem while implementing chamfer matching program in OpenCV

https:// code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/chamfer.cpp?rev=4194

Following is the code it is reading template image

http://img593.imageshack.us/img593/6391/5klx.png

and test image http://img5.imageshack.us/img5/6619/u76z.png

, I am using VS 2008 and OpenCV2.4.6

#include "stdafx.h"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <iostream>
using namespace cv;
using namespace std;

int main( int argc, char** argv )
 {    
IplImage *src;
src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo_in_clutter.png",1);      
Mat img=cvarrToMat(src);  
imshow("Mat",img); 

src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo.png",1);  
Mat tpl=cvarrToMat(src);  
imshow("Mat",tpl); 

// 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);    
vector<vector<Point> > results;
vector<float> costs;
int best = chamerMatching( img, tpl, results, costs );
if( best < 0 )
{
    cout << "not found;\n";
    return 0;
}    
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();
return 0;
}

this is the error image http://img138.imageshack.us/img138/7339/m1d.png

can you suggest me why I am getting this error as I am new to OpenCV and Image Processing

click to hide/show revision 2
retagged

updated 2013-10-04 08:58:30 -0600

berak gravatar image

debug assertion failed vc\include\vector vector iterator + offset out of range in chamferMatching Opencv

am stuck with the problem while implementing chamfer matching program in OpenCV

https:// code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/chamfer.cpp?rev=4194

Following is the code it is reading template image

http://img593.imageshack.us/img593/6391/5klx.png

and test image http://img5.imageshack.us/img5/6619/u76z.png

, I am using VS 2008 and OpenCV2.4.6

#include "stdafx.h"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <iostream>
using namespace cv;
using namespace std;

int main( int argc, char** argv )
 {    
IplImage *src;
src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo_in_clutter.png",1);      
Mat img=cvarrToMat(src);  
imshow("Mat",img); 

src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo.png",1);  
Mat tpl=cvarrToMat(src);  
imshow("Mat",tpl); 

// 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);    
vector<vector<Point> > results;
vector<float> costs;
int best = chamerMatching( img, tpl, results, costs );
if( best < 0 )
{
    cout << "not found;\n";
    return 0;
}    
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();
return 0;
}

this is the error image http://img138.imageshack.us/img138/7339/m1d.png

can you suggest me why I am getting this error as I am new to OpenCV and Image Processing

debug assertion failed vc\include\vector vector iterator + offset out of range in chamferMatching Opencv

I am stuck with the problem while implementing chamfer matching program in OpenCV

https:// code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/chamfer.cpp?rev=4194https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/chamfer.cpp?rev=4194

Following is the code it is reading template image

http://img593.imageshack.us/img593/6391/5klx.png

and test image http://img5.imageshack.us/img5/6619/u76z.png

, I am using VS 2008 and OpenCV2.4.6

#include "stdafx.h"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <iostream>
using namespace cv;
using namespace std;

int main( int argc, char** argv )
 {    
IplImage *src;
src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo_in_clutter.png",1);      
Mat img=cvarrToMat(src);  
imshow("Mat",img); 

src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo.png",1);  
Mat tpl=cvarrToMat(src);  
imshow("Mat",tpl); 

// 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);    
vector<vector<Point> > results;
vector<float> costs;
int best = chamerMatching( img, tpl, results, costs );
if( best < 0 )
{
    cout << "not found;\n";
    return 0;
}    
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();
return 0;
}

this is the error image http://img138.imageshack.us/img138/7339/m1d.png

can you suggest me why I am getting this error as I am new to OpenCV and Image Processing

debug assertion failed vc\include\vector vector iterator + offset out of range in chamferMatching Opencv

I am stuck with the problem while implementing chamfer matching program in OpenCV

https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/chamfer.cpp?rev=4194

Following is the code it is reading template image

http://img593.imageshack.us/img593/6391/5klx.png

and test image http://img5.imageshack.us/img5/6619/u76z.png

, I am using VS 2008 and OpenCV2.4.6

#include "stdafx.h"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <iostream>
using namespace cv;
using namespace std;

int main( int argc, char** argv )
 {    
IplImage *src;
src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo_in_clutter.png",1);      
Mat img=cvarrToMat(src);  
imshow("Mat",img); 

src = cvLoadImage("C:\\Users\\JOSHI\\Desktop\\Images\\logo.png",1);  
Mat tpl=cvarrToMat(src);  
imshow("Mat",tpl); 
Mat cimg;

// 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);    
vector<vector<Point> > results;
vector<float> costs;
int best = chamerMatching( img, tpl, results, costs );
if( best < 0 )
{
    cout << "not found;\n";
    return 0;
}    
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();
return 0;
}

this is the error image http://img138.imageshack.us/img138/7339/m1d.png

can you suggest me why I am getting this error as I am new to OpenCV and Image Processing