Aiming at the problems of personnel intrusion and random placement of goods affecting driving safety in the process of forklift operation, an obstacle target detection and distance detection method for forklift operation based on improved YOLOv5 network is proposed. First, in view of the problem that the target is small and difficult to detect when the distance between people is long, the YOLOv5 network is improved to improve the accuracy of target detection; for the problem of tracking loss caused by the detection target being occluded, the target tracking algorithm and ranging algorithm are introduced to realize the target detection. tracking recognition and distance detection. The experimental results show that the detection accuracy of the improved YOLOv5 network is improved by 4%; within the dangerous distance range, the distance detection error is within 5%, which meets the requirements of real-time detection and distance detection, and can be used to detect potential dangerous situations during operation. Give an early warning.