1 | initial version |
I think that what you are looking for is a shape detection algorithm. If you make a search in the internet I think that you will easily find several approaches. Have a look here to get an idea. I hope that it will help you.