Here is an approach to motion detection using OpenCV and python.