Non-contact measurement of 3-D surface has been extensively applied in industry. The stereo vision is an effective way for 3-D profile measurement.Distinguishing and detecting the high density white-black stripes is one of the key techniques in the 3D-measurement based on the image of grating. Using spatial code technology, the measurement space was divided to several parts, and each part corresponded with a unique binary code. Falling on the space part, there was a unique binary code corresponded with the stripes, thus the stripes could be distinguished accurately. After getting pixel stripes with edge detection algorithm, the high precision strips could be detected by sub-pixel technology. The sub-pixel edge detection algorithm based on gray moment and polynomial fitting was presented. Combining spatial code and sub-pixel technique, it could easily distinguish and detect the sub-pixel stripes. This method can obtain a higher precision comparing with pixel stripes detection and improve the accuracy of measurement system.