I found many ways to detect different shapes. But hard luck when I am going for a physical object. From what I read we should have a black border around images to make a pat
I recently read about research being doing on hierarchical shape vocabularies used for object representation. Of course, there is no library available for download, but in case you are interested in the general approach here you can find some papers.
Also you might be interested in this paper. It describes an algorithm for detecting objects based on a set of contours.