Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv Contour Error

I want to find contours of my image then I want to draw contour using openCV. I'm using VS 2012 and OpenCV 2.4.5 I wrote sample code about finding contours and drawing contours. Bu I stacked that horrible error :) For any help I will be appreciated

void MyClass::findContoursAndDraw(cv::Mat image,int b,int g,int r)
{
findContours(image,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
for(int i=0;i<contours.size();i++)
{
int size=cv::contourArea(contours[i]);
if(size>500)
{
    printf("%i \n",size);
    drawContours(originalTemp,contours,i,cv::Scalar(b,g,r),2,8);        
}

}
}

void MyClass::findContoursAndDrawFilled(cv::Mat image,int b,int g,int r)
{
findContours(image,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
for(int i=0;i<contours.size();i++)
{
    int size=cv::contourArea(contours[i]);
    if(size>3000)
   {
    printf("%i \n",size);
    drawContours(originalImg,contours,i,cv::Scalar(b,g,r));     
}

}
}

My threshold and other necessary function works very well. But My program stacked at finding contour and drawcontour function. Says that:

 Unhandled exception at 0x00B3A52A (opencv_imgproc245d.dll) in OpencvTest.exe: 
 0xC0000005: Access violation reading location 0xCDCDCDCD