Real-time segmentation of scene into foreground and background is an important issue for many applications. Different from previous codebook (CB) methods, this paper introduces a hybrid CB model by combining the mixture of Gaussian (MOG) method and the CB method. It can be used to solve the problems of moving background and shadow/highlight on the background and background. Our method avoids extracting false foreground pixels or missing real foreground pixels. The experimental results illustrate the advantages of our method over the other methods.