图像练习-识别中圆形锡点 (04)

图片

代码

cpp 复制代码
	cv::Mat src = cv::imread("light_point.png", cv::IMREAD_COLOR);

	cv::Mat draw = src.clone();
	cv::Rect rt0(20, 80, src.cols - 30, 190);
	cv::Rect rt1(20, 480, src.cols - 30, 190);

	cv::Mat gray;
	cv::cvtColor(src, gray, cv::COLOR_BGR2GRAY);

	cv::Mat dst(gray.size(), gray.type(), cv::Scalar(0));

	gray(rt0).copyTo(dst(rt0));
	gray(rt1).copyTo(dst(rt1));

	cv::Mat gauss;
	cv::GaussianBlur(dst, gauss, cv::Size(45, 45), 0.0);

	cv::Mat binary = gauss > 90;

	std::vector<std::vector<cv::Point>> contours;
	cv::findContours(binary, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_NONE);

	cv::Mat marker = src.clone();
	for (size_t i = 0; i < contours.size(); ++i)
	{
		cv::Point2f center;
		float radius = 0.0f;
		cv::minEnclosingCircle(contours[i], center, radius);
		cv::RotatedRect rRect = cv::fitEllipse(contours[i]);
		cv::drawMarker(marker, rRect.center, cv::Scalar(255), cv::MARKER_CROSS);
		cv::circle(marker, center, (int)radius, cv::Scalar(0, 255));
	}

结果

相关推荐
正在走向自律5 分钟前
GpuGeek 网络加速:破解 AI 开发中的 “最后一公里” 瓶颈
网络·人工智能·python·机器学习·性能优化·gpugeek
正儿八经的数字经24 分钟前
人工智能100问☞第24问:什么是生成对抗网络(GAN)?
人工智能·神经网络·生成对抗网络
wei_shuo1 小时前
GpuGeek 实操指南:So-VITS-SVC 语音合成与 Stable Diffusion 文生图双模型搭建,融合即梦 AI 的深度实践
人工智能·stable diffusion·gpu算力·gpuseek
x-cmd1 小时前
[250516] OpenAI 升级 ChatGPT:GPT-4.1 及 Mini 版上线!
人工智能·chatgpt·openai·gpt-4.1
2201_754918412 小时前
OpenCV 背景建模详解:从原理到实战
人工智能·opencv·计算机视觉
CopyLower2 小时前
苹果计划将AI搜索集成至Safari:谷歌搜索下降引发的市场变革
前端·人工智能·safari
wd2099882 小时前
2025年Ai写PPT工具推荐,这5款Ai工具可以一键生成专业PPT
人工智能
张飞飞飞飞飞2 小时前
语音识别——声纹识别
人工智能·语音识别
archko3 小时前
语音识别-3,添加ai问答
android·人工智能