Motion detection

Motion detection is the process of detecting a change in the position of an object relative to its surroundings or a change in the surroundings relative to an object. It can be achieved by either mechanical or electronic methods. When it is done by natural organisms, it is called motion perception.
Methods.
Motion can be detected by monitoring changes in:
Mechanical.
The most basic forms of mechanical motion detection utilize a switch or trigger. For example, the keys of a typewriter use a mechanical method of detecting motion, where each key is a switch that is either off or on, and each letter that appears is a result of the key's motion.
Electronic.
The principal methods by which motion can be electronically identified are optical and acoustic. Infrared light or laser technology can be used for optical detection. Motion-detection devices such as PIR motion detectors have a sensor that detects a disturbance in the infrared spectrum. A signal can then activate an alarm, and/or a camera to capture an image or video of the event.
This method's chief applications are:
A simple algorithm for motion detection by a fixed camera compares the current image with a reference image and monitors the number of different pixels. Since images naturally differ due to factors such as varying lighting, camera flicker, and CCD dark currents, pre-processing is useful to reduce the number of false positive alarms.
More complex algorithms are necessary to detect motion when the camera itself is panning, or when a specific object's motion must be detected in a field containing other, irrelevant movement—for example, a painting surrounded by visitors in an art gallery. With a panning camera, models based on optical flow are used to distinguish between apparent background motion caused by the camera's movement and that of independently moving objects.
Devices.
Motion detectors are often integrated components of systems that automatically perform tasks, or alert users of motion in an area. An occupancy sensor detects the entry or movement of a person or thing within a certain space.
Motion controllers are also used for video game consoles as game controllers. A camera can also allow the body's movements to be used for control, such as in the Kinect system.