1. A non-transitory computer-readable medium encoded with a computer program comprising instructions that, when executed, operate to cause a computer to perform operations comprising: defining a shape within motion data, the motion data comprising a motion history map that includes motion history data values providing, for each point of an image, an indication of time since a moving object was detected at the point; determining, for each point, whether the moving object has been detected within a predetermined period of time, and grouping adjacent points determined to have detected motion of the moving object within the predetermined period of time; sampling the motion data at one or more of the grouped points that are aligned with the defined shape; determining whether a moving object is performing a gesture correlating to the defined shape based on a pattern exhibited by the sampled motion data; and controlling an application if determining that the moving object is performing the gesture.