how to detect shapes in python