1. A memory medium comprising program instructions for detecting patterns in an image, wherein the program instructions are executable to implement: in a learning phase, storing a template image in a memory medium; +P2 determining a plurality of geometric features present in the template image; creating a model for each of a plurality of respective parent features, wherein each model comprises a relationship tree from the respective parent feature to one or more other child features; in a matching phase, a) receiving a target image; b) extracting first geometric features from the target image that correspond to a first parent feature in a first model; c) matching the first parent feature to the first geometric features from the target image to determine a first one or more matches; d) extracting second geometric features from the target image that correspond to at least one child feature in the first model; e) matching the at least one child feature to the second geometric features from the target image; f) updating any of the first one or more matches in response to matching the at least one child feature to the second geometric features from the target image; (g) performing b)-f) for each of a plurality of models; and storing information regarding one or more matches in the target image.