Underwater target localization technology plays a vital role in the development and utilization of marine resources. Due to the multipath effect in the hydroacoustic channel, the received signal is the superposition of a series of direct and reflected acoustic paths, making it challenging to accurately identify the direct path using existing methods. To address this issue, this paper proposes a high-precision direct path recognition method based on LightGBM, which utilizes the amplitude, Time of Arrival (TOA), reception angle, and phase of the received pulse as input features. Meanwhile, due to the propagation time of acoustic waves from transmitter to receiver cannot be linearly converted to a distance value, as in the case of radio ranging in air, a method based on Effective Sound Velocity (ESV) is introduced to compensate for the bending of sound rays. By utilizing the recognized direct path delay value and the sound velocity value after compensating for sound ray bending, we can calculate the precise position of underwater targets. Experimental results validate the effectiveness of the proposed method in significantly improving the accuracy of underwater target localization.