Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to find circles in an image

Hi in the below image how do you find and mark all the circles and identify the defect, my vs is vs2010 and opencv 2.4.10

image description

How to find circles in an image

Hi in the below image how do you find and mark all the circles and identify the defect, my vs is vs2010 and opencv 2.4.10

image descriptionimage description

How to find circles in an image

Hi in the below image how do you find and mark all the circles and identify the defect, my vs is vs2010 and opencv 2.4.10

image description

this is my code so far, but it doesnt detect anything

static void findCircles2(const Mat& image)

{ vector<vec3f> circles; int thresh1 = 5; Mat pyr, timg, gray0(image.size(), CV_8U), gray; pyrDown(image, pyr, Size(image.cols/2, image.rows/2)); pyrUp(pyr, timg, image.size()); for( int c = 0; c < 3; c++ ) { int ch[] = {c, 0}; mixChannels(&timg, 1, &gray0, 1, ch, 1); Canny(gray0, gray, 0, thresh1, 5); //dilate(gray, gray, Mat(), Point(-1,-1)); gray = gray0 >= (1)255/N; gray = gray0 >= (2)255/N; gray = gray0 >= (6)*255/N; namedWindow( "Hough Circle Transform Demo 1", CV_WINDOW_AUTOSIZE ); imshow( "Hough Circle Transform Demo 1", gray ); waitKey(0);

    HoughCircles( gray, circles, CV_HOUGH_GRADIENT, 1, gray.rows/8, 200, 100, 0, 0 );
    cout<<"size of circles: "<<circles.size()<<endl;
    for( size_t i = 0; i < circles.size(); i++ )
    {
        Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
        int radius = cvRound(circles[i][2]);
        circle( gray, center, 3, Scalar(0,255,0), -1, 8, 0 );
        circle( gray, center, radius, Scalar(0,0,255), 3, 8, 0 );
    }

/// Show your results namedWindow( "Hough Circle Transform Demo 2", CV_WINDOW_AUTOSIZE ); imshow( "Hough Circle Transform Demo 2", gray );

     waitKey(0);

}

}

How to find circles in an image

Hi in the below image how do you find and mark all the circles and identify the defect, my vs is vs2010 and opencv 2.4.10

image description

this is my code so far, but it doesnt detect anythinganything.

static void findCircles2(const Mat& image)

{ vector<vec3f> circles; int thresh1 = 5; Mat pyr, timg, gray0(image.size(), CV_8U), gray; pyrDown(image, pyr, Size(image.cols/2, image.rows/2)); pyrUp(pyr, timg, image.size()); for( int c = 0; c < 3; c++ ) { int ch[] = {c, 0}; mixChannels(&timg, 1, &gray0, 1, ch, 1); Canny(gray0, gray, 0, thresh1, 5); //dilate(gray, gray, Mat(), Point(-1,-1)); gray = gray0 >= (1)255/N; gray = gray0 >= (2)255/N; gray = gray0 >= (6)*255/N; namedWindow( "Hough Circle Transform Demo 1", CV_WINDOW_AUTOSIZE ); imshow( "Hough Circle Transform Demo 1", gray ); waitKey(0);

    HoughCircles( gray, circles, CV_HOUGH_GRADIENT, 1, gray.rows/8, 200, 100, 0, 0 );
    cout<<"size of circles: "<<circles.size()<<endl;
    for( size_t i = 0; i < circles.size(); i++ )
    {
        Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
        int radius = cvRound(circles[i][2]);
        circle( gray, center, 3, Scalar(0,255,0), -1, 8, 0 );
        circle( gray, center, radius, Scalar(0,0,255), 3, 8, 0 );
    }

/// Show your results namedWindow( "Hough Circle Transform Demo 2", CV_WINDOW_AUTOSIZE ); imshow( "Hough Circle Transform Demo 2", gray );

     waitKey(0);

}

}

How to find circles in an image

Hi in the below image how do you find and mark all the circles and identify the defect, my vs is vs2010 and opencv 2.4.10

image description

this is my code so far, but it doesnt detect anything.anything:

static void findCircles2(const Mat& image)

{ vector<vec3f> vector<Vec3f> circles; int thresh1 = 5; Mat pyr, timg, gray0(image.size(), CV_8U), gray; pyrDown(image, pyr, Size(image.cols/2, image.rows/2)); pyrUp(pyr, timg, image.size()); for( int c = 0; c < 3; c++ ) { int ch[] = {c, 0}; mixChannels(&timg, 1, &gray0, 1, ch, 1); Canny(gray0, gray, 0, thresh1, 5); //dilate(gray, gray, Mat(), Point(-1,-1)); gray = gray0 >= (1)255/N; (1)*255/N; gray = gray0 >= (2)255/N; (2)*255/N; gray = gray0 >= (6)*255/N; namedWindow( "Hough Circle Transform Demo 1", CV_WINDOW_AUTOSIZE ); imshow( "Hough Circle Transform Demo 1", gray ); waitKey(0);

waitKey(0);

        HoughCircles( gray, circles, CV_HOUGH_GRADIENT, 1, gray.rows/8, 200, 100, 0, 0 );
     cout<<"size of circles: "<<circles.size()<<endl;
     for( size_t i = 0; i < circles.size(); i++ )
     {
         Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
         int radius = cvRound(circles[i][2]);
         circle( gray, center, 3, Scalar(0,255,0), -1, 8, 0 );
         circle( gray, center, radius, Scalar(0,0,255), 3, 8, 0 );
     }

/// Show your results namedWindow( "Hough Circle Transform Demo 2", CV_WINDOW_AUTOSIZE ); imshow( "Hough Circle Transform Demo 2", gray );

);

         waitKey(0);

    }
}

}