OpenCV特征检测(8)检测图像中圆形的函数HoughCircles()的使用 - GaussianBlur( gray, gray, Size(9, 9), 2, 2 )
操作系统:ubuntu22.04
OpenCV版本:OpenCV4.9
IDE:Visual Studio Code
编程语言:C++11
算法描述
在灰度图像中使用霍夫变换查找圆形。
该函数使用霍夫变换的一种修改版本在灰度图像中查找圆形。 例子:
#include
#include
#include
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat img, gray;
if( argc != 2 || !(img=imread(argv[1], IMREAD_COLOR)).data)
return -1;
cvtColor(img, gray, COLOR_BGR2GRAY);
// smooth it, otherwise a lot of false circles may be detected 拼多多帮助力入口
GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
vectorcircles;
HoughCircles(gray, circles, HOUGH_GRADIENT,
2, gray.rows/4, 200, 100 );
for( size_t i = 0; i < circles.
OpenCV特征检测(8)检测图像中圆形的函数HoughCircles()的使用
参考文章