In this paper, we propose a method in combination of vehicle detection and virtual detector to count the number of vehicles on road in real time. It draws a set of rectangular regions of interest (ROIs) in each lane as the virtual detector in image space, and determines the presence of vehicles by monitoring changes in area of virtual detector. The virtual detector in running system is highlighted with the thin red rectangular box and shown in Fig. 3(a). While vehicles pass through the virtual detector, pixel changes in histogram can be found as shown in Fig. 3(b).