Ductile cast iron pipes (DCIPs) are widely utilized in water and gas supply due to their exceptional mechanical and material properties. Quality control during production is paramount for optimal performance, with surface defect detection being of utmost importance. Currently, production sites primarily rely on manual visual inspection, which presents several challenges, including high labor intensity, low efficiency, and subjectivity in defect judgment. 2D detection algorithms based on single images struggle to effectively detect small defects such as pores, pinholes, and scratches, resulting in high missed detection rates and vulnerability to interference from oil and water stains. To address these issues, this paper proposes a symmetrical twin-light photometric stereo (TLPS) detection algorithm based on photometric stereo theory, and image correction algorithm for mitigating the effects of ambient light. A visual inspection prototype system was designed and successfully implemented at a production site. The system comprises eight visual inspection units, each equipped with a high-speed line scan camera and two bar light sources for image acquisition of moving DCIP. Under the Lambertian model and parallel light source assumption, the gradient expression in the texture direction of the DCIP surface is derived based on light source symmetry. Production experiment results demonstrate that the gradient map obtained through the proposed TLPS effectively enhances defect contrast and accurately detects and locates micro defects such as pores, pinholes, and scratches on cast pipe surfaces. This verifies the effectiveness of the TLPS algorithm, addresses the shortcomings of traditional 2D detection algorithms, and lays the foundation for subsequent online detection of DCIP surface defects.