Detect objects similar to circles

前端 未结 2 1475
既然无缘
既然无缘 2021-02-04 17:20

I\'m trying to detect objects that are similar to circles using OpenCV\'s HoughCircles. The problem is: HoughCircles fails to detect such objects in so

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 17:40

    Give try on below,

    1. Find contour in source.

    2. Find minimum enclosing circle for the contour.

    3. Now draw contour to new Mat with CV_FILLED.

    4. Similarly draw enclosing circle to new Mat with filled option.

    5. Perform x-or operation between the above two and count non-zero.

    6. You can decide the contour is close to circle or not by comparing the non-zero pixel between contour and enclosimg circle with a threshold. You can decide the threshold by calculating the area of encosing circle, and taking it percent.

    The idea is simple the area between contour and its enclosing circle decreases as the contour closes to circle

提交回复
热议问题