java hough_java – HoughCircles发现错误的圈子(opencv)

我有下面的图片,我真正想要检测的是盒子上方的圆圈,每个方框的左上角都有字母.但结果是它还检测到其他一些圈子.我不知道为什么.

我要检测的图像:

这就是结果:

正如你所看到的,它有时可以找到圆圈的字母,也可以找到乐高的圆圈.这是我的代码:

Mat source = Highgui.imread("testar.jpg", Highgui.CV_LOAD_IMAGE_COLOR);

Mat destination = new Mat(source.rows(), source.cols(), source.type());

Imgproc.cvtColor(source, destination, Imgproc.COLOR_RGB2GRAY);

Imgproc.GaussianBlur(destination, destination, new Size(3,3),0,0);

Mat circles = new Mat();

Imgproc.HoughCircles(destination, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 20, 10, 20, 7, 13);

int radius;

Point pt;

for (int x = 0; x < circles.cols(); x++) {

double vCircle[] = circles.get(0,x);

if (vCircle == null)

break;

pt = new Point(Math.round(vCircle[0]), Math.round(vCircle[1]));

radius = (int)Math.round(vCircle[2]);

// draw the found circle

Core.circle(destination, pt, radius, new Scalar(0,255,255), 3);

Core.circle(destination, pt, 3, new Scalar(255,255,255), 3);

}

Highgui.imwrite("foundCircles.jpg", destination);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值