Abstract. Building on the current understanding of neural architecture of the visual cortex, we present a graphical model for learning and classification of motion patterns in videos. The model is composed of an arbitrary amount of Hidden Markov Models (HMMs) with shared Gaussian mixture models. The novel extension of our model is the use of additional Markov chain, serving as a switch for indicating the currently active HMM. We therefore call the model a Switching Hidden Markov Model (SHMM). SHMM learns from input optical flow in an unsupervised fashion. Functionality of the model is tested with artificially simulated time sequences. Tests with real videos show that the model is capable of learning and recognition of motion activities of single individuals, and for classification of motion patterns exhibited by groups of people. Classification rates of about 75 percent for real videos are satisfactory taking into account a relative simplicity of the model.