Abstract: This study is designed to develop an advanced safety system that is able to detect the existence of moving obstacles at a railway crossing. In a miniature railway crossing, scaled 1:22.5, the authors installed a grayscale CCD camera and developed a graphical user interface to process the images of the crossing. To achieve this goal, the software was programmed to perform several image processing techniques such as image subtraction, binarization, morphological transformation and segmentation to track down the moving obstacles. In addition, portions of the monitored image around the rails were labeled as alert and alarm zones where detected obstacles would trigger the sirens of this system. Under various lighting conditions for the model cars with different colors in the indoor environment, the experiments on the developed system demonstrated that the level of illuminance was a significant factor affecting the average alert accuracy rate but the color of cars was not. Overall, the average alert accuracy rate reached 97.8%. The promising results of the systems capability to recognize obstacles that might pose threats, merit pursuit of full-scale development at railway crossing sites to provide effective protection against previously undetected, now preventable incidents.