The real-time and accurate detection and ranging of ships play a pivotal role in ensuring navigation safety, this study aims to enhance the navigation safety and environmental perception capabilities of inland waterway vessels. In the ship detection stage, addressing challenges such as large parameters, high computational complexity, and poor real-time performance in existing ship detection models, this paper proposes the MS-YOLOv5s ship target detection algorithm. This algorithm, based on YOLOv5s, utilizes the lightweight MobileNetV3-Small network to replace the original YOLOv5s feature extraction backbone network, thereby improving the detection speed. The results indicate that the parameter size of the MS-YOLOv5s model is 3.55M, only 50.49% of YOLOv5s. Achieving a detection rate of 50.28 FPS, the precision is 96.80%, and the mAP is 98.40%, striking a balance between high accuracy and low computational demand. In the depth estimation stage, influenced by the environment, leading to unstable measurement data, this paper proposes a binocular Kalman filter fusion ranging algorithm. The standard deviation of the ranging results is minimized to 6.032μm, which is one order of magnitude smaller than traditional ranging algorithms, significantly enhancing the robustness of the measurement results. Within a distance of 20m from the ship target, the error can be controlled within 3%, showcasing the applicability of the method proposed in this paper in complex inland waterway environments contributes to the enhancement of ships' environmental perception capabilities and navigation safety, holding positive implications for the development of intelligent vessels.