OpenCV图像处理实战笔记系列---04 霍夫圆检测

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;
int main(int argc, char** argv) {
	Mat src = imread("E:/images/test.jpg");
	Mat gray;
	cvtColor(src, gray, COLOR_BGR2GRAY);
	GaussianBlur(gray, gray, Size(3, 3), 2, 2);
	imshow("gray", gray);
	vector<Vec3f> circles;
	double minDist = 40;
	double min_radius = 20;
	double max_radius = 50;
	HoughCircles(gray, circles, HOUGH_GRADIENT, 3, minDist, 100, 100, min_radius, max_radius);
	for (size_t t = 0; t < circles.size(); t++) {
		Point center(circles[t][0], circles[t][1]);
		int radius = round(circles[t][2]);
		// 绘制圆
		circle(src, center, radius, Scalar(0, 0, 255), 2, 8, 0);
		//绘制圆心
		circle(src, center, 3, Scalar(255, 0, 0), 2, 8, 0);
		

	}
	imshow("hough circle demo", src);

	waitKey(0);
	destroyAllWindows();
	return 0;

欢迎关注微信公众号:小白的计算机视觉之路
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值