firewall
firewall

Reputation: 638

Detect a shape that is close to a circle using Hough in OpenCV

I'm still a beginner in OpenCV, and I'm trying to detect circles using HoughCircles with the following parameters:

HoughCircles(gray, circles, CV_HOUGH_GRADIENT,2, gray.rows/8, 200, 90, 0, 130 );

However, HoughCircles is not detecting shapes that are closely similar to a circle, as in the image below.

Do you have an idea on how to fix such issue?

Thank you in advance.

enter image description here

Upvotes: 4

Views: 2474

Answers (1)

Rob Audenaerde
Rob Audenaerde

Reputation: 20019

Hough is used to find near perfect circles. it is robust to holes and noise, but not to deformations.

You might want to try to find a measure of 'circle-likeness'. You could analyze the contours, by comparing the length vs the surface. If it is close to pi, you know you have a circular shape.

Upvotes: 1

Related Questions