Parsing images with finite state machines for object class