To the pipeline welding defect detection, robot tracking weld reliably, the welds original image acquired by visual sensor need pretreatment to eliminate the impact of noise. A pipeline welding machine vision detection method proposed in this paper. First of all, the use of neighborhood mean filter for smoothing, the largest variance threshold method selecting adaptive threshold to segmentation image. Image after smooth will be the binarization processing. Then remove the small area noise with labeling method, get a clear image of the weld. The level of projection method to the recognition of weld image and determine the location of weld. The experiments show that the pretreatment method solute the prevailing situation of uneven illumination, and also reducing the size of the processing image, reducing the amount of data, saving time, meeting the needs of the pipeline weld tracking real-time detection, laying a solid foundation for follow-up quality inspection.