Motion detect | RPi with Full-HD Camera

Nowdays, the availability of cheap Full-HD grade camera for the RPi leverages the need for a broad range of project in the fields of security and access control. One of the simplest (while powerful) use of a camera is motion detect. Motion detect applied to a RPi can be part of an intrusion detection system, in turn this system itself may be part of a global alarm system.
Another field of use is the access control system. A camera equipped RPi could manage face recognition on its own and then grant/refuse access to a place. This later will be part of an upcomming project involving the openCV library.

Principles

The principle of motion detect itself is very simple. A camera takes a picture let's say every 1s and then apply simple comparison between two successives images. If there's more than X pixels difference then it's time to both trigger an alarm and to start recording.