Vehicle detection and classification are invaluable in many transportation systems, such as traffic flow analysis, abnormal events detection, automotive driver assistant systems and so on. Many vehicle detection systems have been proposed so far. However, there are still some problems not well solved yet. One of the crucial problems is how to eliminate shadows cast by moving vehicles. In this paper, we propose a novel method based on combination of HMM and background subtraction. A public database of shadow: http://cvrr.ucsd.edu/aton/shadow is employed to test the performance of the new algorithm. Result shows that the proposed method is much better than other old methods.