Stereo matching is one of the fundamental problems in computer vision. It consists in identifying features in two or more stereo images that are generated by the same physical feature in the three-dimensional space. This paper presents an evolutionary approach with a multilevel searching strategy for matching edges extracted from two stereo images. The matching problem is turned into an optimization task, which is performed by means of a genetic algorithm with a new encoding scheme. For an effective exploitation of the genetic stereo matching algorithm for real-time obstacle detection, a multilevel searching strategy is proposed to match the edges at different levels by considering their gradient magnitudes. Experimental results and comparative analysis are presented to demonstrate the effectiveness of the proposed method for real-time obstacle detection in front of a moving vehicle using linear stereo vision.