This is a pretty classic computer vision problem that combines detection, tracking, filtering, recognition, and logical parsing together into one system whose objective is to make sense of the comings and goings of people or objects within a scene. It is one of the few of the modules that requires some nominal level of system integration to get running properly. Matlab has Simulink code that does this for the case of abandoned object detection, which is documented online, so you can see one expected outcome of a surveillance system.
/* I also found this might be useful too: http://studentdavestutorials.weebly.com/particle-filter-with-matlab-code.html This website covers areas such as Bayes rule, Kalman filter and particle filter with short videos and Matlab implementation. The tracker parts(Kalman filter and particle filter) may be included to learning modules. */
The sequence below introduces one aspect of surveillance systems at a time. They direct you to Matlab code that sometimes implements multiple steps at a time. It is recommended that you implement each one individually to get a sense for what role it plays in the entire system, rather than just copy/paste the whole system.
Module Set #1: A Basic (Foreground Detection-Based) Surveillance System
Module Set #2: Target Modelling and Re-Identification
Module #3: Merging and Splitting
Module #4: Tracking vs Detection
Sample videos from past teams:
Presentations by researchers in computer vision
Online talks
Advertisement Videos of companies that provide surveillance algorithms as a service: