登录后台

页面导航

本文编写于 434 天前,最后修改于 434 天前,其中某些信息可能已经过时。

out.jpg
c.jpg

cv::Mat a = cv::imread("c.jpg");
Mat img, imgs[3];
GaussianBlur(a, img, Size(5, 5), 25, 25);
cv::split(img, imgs);
img = imgs[0];
cv::HoughCircles(img, circles, HOUGH_GRADIENT, 1, 150, 100, 50, 10, 140);
for (size_t i = 0; i < circles.size(); i++)
{
    Point center(cvRound(circles[i][0]), cvRound(circles[i][0]));
    int radius = cvRound(circles[i][2]);
    circle(a, center, 3, Scalar(100, 100, 100), -1, 8, 0);
    circle(a, center, radius, Scalar(132, 0, 156), 3, 8, 0);
}

cv::imwrite("out.jpg", a);

cv::imshow("c", a);
cv::waitKey(0);