Ask Your Question

Revision history [back]

Hi.. i'm new to opencv and trying shape detection. I have faced the following error "Unhandled exception (opencv_imgproc243d.dll) in ShapeDetection.exe " Can anyone knows how to solve this???

My program, int main() { //cv::Mat src = cv::imread("polygon.png"); cv::Mat src; cv::Mat gray; cv::Mat bw; cv::Mat dst;

std::vector<cv::Point> approx;
std::vector<std::vector<cv::Point>> contours;

VideoCapture capture(0);
int q;

while (cvWaitKey(30) != 'q')
{
    capture >> src;
    if (true)
    {
        // Convert to grayscale
        cv::cvtColor(src, gray, CV_BGR2GRAY);

        // Use Canny instead of threshold to catch squares with gradient shading
        blur(gray, bw, Size(3, 3));
        cv::Canny(gray, bw, 80, 240, 3);
        cv::imshow("bw", bw);
        //cv::bitwise_not(bw, bw);

        // Find contours
        cv::findContours(bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

        src.copyTo(dst);

        for (int i = 0; i < contours.size(); i++)
        {
            // Approximate contour with accuracy proportional
            // to the contour perimeter
            cv::approxPolyDP(cv::Mat(contours[i]), approx, cv::arcLength(cv::Mat(contours[i]), true)*0.02, true);

            // Skip small or non-convex objects
            if (std::fabs(cv::contourArea(contours[i])) < 100 || !cv::isContourConvex(approx))
                continue;

..................

Facing the problem in the for loop when i=1 and breaks at point cv::approxPolyDP().

click to hide/show revision 2
No.2 Revision

updated 2016-11-17 00:42:04 -0600

berak gravatar image

Hi.. i'm new to opencv and trying shape detection. I have faced the following error "Unhandled exception (opencv_imgproc243d.dll) in ShapeDetection.exe " Can anyone knows how to solve this???

My program, program,

int main()
{
    //cv::Mat src = cv::imread("polygon.png");
    cv::Mat src;
    cv::Mat gray;
    cv::Mat bw;
    cv::Mat dst;

dst;

    std::vector<cv::Point> approx;
 std::vector<std::vector<cv::Point>> contours;

 VideoCapture capture(0);
 int q;

 while (cvWaitKey(30) != 'q')
 {
     capture >> src;
     if (true)
     {
         // Convert to grayscale
         cv::cvtColor(src, gray, CV_BGR2GRAY);

         // Use Canny instead of threshold to catch squares with gradient shading
         blur(gray, bw, Size(3, 3));
         cv::Canny(gray, bw, 80, 240, 3);
         cv::imshow("bw", bw);
         //cv::bitwise_not(bw, bw);

         // Find contours
         cv::findContours(bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

         src.copyTo(dst);

         for (int i = 0; i < contours.size(); i++)
         {
             // Approximate contour with accuracy proportional
             // to the contour perimeter
             cv::approxPolyDP(cv::Mat(contours[i]), approx, cv::arcLength(cv::Mat(contours[i]), true)*0.02, true);

             // Skip small or non-convex objects
             if (std::fabs(cv::contourArea(contours[i])) < 100 || !cv::isContourConvex(approx))
                 continue;
..................

..................

Facing the problem in the for loop when i=1 and breaks at point cv::approxPolyDP().