Advanced Motion Detection Algorithm for Patient Monitoring