Detection and extraction of obstacles in a railroad crossing was investigated. A video camera placed over the crossing is used for capturing the image. Realtime object detection was performed by calculating the difference between input and background image. The background image is renewed to adapt to the change of lighting. Using record of brightness of past images, adaptation to the drastic change of lighting is also possible. If the detected object is partially lacked, it is corrected by considering the shape of edge. Under the several lighting conditions, detection rate of the car, the bicycles and the walker were 97%, 82% and 75% on average respectively.