Vibe algorithm is easy to produce ghost and slow moving objects are easy to integrate into the background sample model. A new algorithm was proposed,first of all, using an iterative selection method to distinguish ghost shadow after detecting moving target with ViBe algorithm. Secondly, the edge feature of the image is obtained by using the improved Canny operator, and when the ViBe algorithm updates the background pixel model at the edge of the target, it does not update the pixel model of its neighborhood, so that the time of the slow moving target into the background pixel model is extended, and finally the complete moving target is obtained by morphological processing. Experimental results show that compared with the traditional ViBe algorithm, this algorithm can obtain higher detection accuracy more quickly in the case of ghosts, and the accuracy decreases later in the case of slow moving targets.