Ask Your Question

How to find coordinates of holes?

asked 2017-08-31 05:39:46 -0500

atul gravatar image

updated 2017-08-31 12:33:51 -0500

LBerger gravatar image

Actually there are many holes on the plate (in pic) and I want to know the coordinates of each and every holes. Is there any method to do so? Can anyone give the code in Open CV.

Please Help me.

Thanks in advance.C:\fakepath\IMG-20170830-WA0000.jpg

edit retag flag offensive close merge delete



please read good-questions-and-answers-how-to and improve your question

sturkmen gravatar imagesturkmen ( 2017-08-31 05:47:10 -0500 )edit

Hi, Can you upload the picture? May be you can use simple threshold method or canny edge detection to detect holes. Always post required details .

vps gravatar imagevps ( 2017-08-31 09:23:40 -0500 )edit

Thanx buddy. Now you can see the pic.

atul gravatar imageatul ( 2017-08-31 10:40:48 -0500 )edit

maybe this will be helpful

sturkmen gravatar imagesturkmen ( 2017-08-31 11:55:37 -0500 )edit

Hey Sturkmen. can u provide me code . Thanks in advance.

atul gravatar imageatul ( 2017-09-01 00:19:49 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-08-31 11:28:24 -0500

What have you tried so far?

A couple methods you could look into are:

  1. Hough Circles

  2. Find the contours then try filtering them out by area or something along those lines. I'd then find the convexHulls (This is an optional step and should be performed depending on the results of the contours). Thereafter I would check the resulting contours/convexHulls for circularity using the equation shown here

You'll need to tweak around with the resulting circularity to see which one makes sense. A perfect circle returns 1. So you might want to filter out the contours based off of a criteria along these lines 0.6 <= circularity <= 1.

This should get you started on contours and here's a resource to find methods for calculating contour areas and perimeter.


Before applying any of these methods, you might want to perform some morphological operations to your image to remove noise. Try them out and see which one is suitable for your application.

Canny Edges might be of interest as well.

Happy coding,

Cheers mate :)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-08-31 05:38:33 -0500

Seen: 405 times

Last updated: Aug 31 '17