In recent years, the demand for automatically counting pedestrians in event sites, buildings, or streets has been increased. Our research group has proposed a real-time counting method of pedestrians from video sequences where the target region is crowded and pedestrians are overlapping. In our method, the video sequences are retrieved from a stationary camera, and a liner virtual gate is set at appropriate location in the video sequences. When there is a difference of pixel value between the current frame and the background image at a pixel on the virtual gate, an optical flow whose origin is the pixel is detected. Detected optical flows are clustered based on their direction, size, and location. Then, the number of pedestrians passing through virtual gate is estimated for each cluster based on the size of cluster. In this paper, we propose a detection method of optical flow as the fundamental step of our counting method. We use block matching algorithm to detect an optical flow from video sequences. By limiting the area of search to surrounding the virtual gate, the calculation amount can be decreased and detailed detection can be accomplished in real time. Through evaluations based on actual video sequences, we confirm that 89% of optical flows can be detected successfully in real time.