Objective In the automatic production line of circular weft knitting robot, the position of the bobbin mouth will change due to the influence of the gravity of the bobbin, the vibration when the bobbin is released, the sliding and other factors during the automatic bobbin changing process of the bobbin changing robot. All these will affect the grasping of the empty bobbin by the mechanical claw. In order to ensure the accurate grasp of the empty yarn bobbin by the mechanical claw, it is necessary to locate the position of the empty yarn bobbin. Method Improved Yolov5 model was adopted to frame the position of the bobbin mouth in the picture, then the Sobel edge detection, threshold segmentation, filtering, and closing operations were adopted to process the image of the framed area, and the empty yarn bobbin aperture and center coordinates were obtained by least square fitting. Finally, the pinhole imaging principle of a monocular camera is adopted to locate the bobbin mouth. Results In terms of model recognition, the accuracy of the four models experimented in this research was more than 99%. The accuracy of the model with the attention mechanism alone was decreased by 0.1%, but the speed was increased. After adding Ghost module alone, the accuracy was reduced by 0.2% relative to the original model, but the number of parameters was reduced by about half of the volume relative to the original model, and the speed is also increased. The accuracy of the new model with Ghost and CBAM modules is 99.2%, the number of parameters is 3.71 M, and the detection speed is 54.3 frames/s. It can be seen that the improved model maintains high accuracy, and has a smaller volume and faster detection speed. The comprehensive performance is better. In terms of yarn bobbin positioning, the maximum absolute values of yarn mouth positioning errors of the drum changing robot on X axis, Y axis and Z axis were 1.3, 1.9 and 0.7 mm, respectively, and the errors of the three axes were all within the allowable range of errors. Under the same testing environment, the detection time of the positioning method based on deep learning is about 2 s, with contrast to the 5 s detection time of the conventional method. The time efficiency of the proposed method was improved by about 150%. Compared with deep learning, conventional algorithms were more susceptible to the influence of environment, which was prone to interference during contour fitting leading to failure in fitting the yarn bobbin correctly. The deep learning method was shown to be able to eliminate the interference of environment effectively and provide favorable conditions for yarn fitting. Conclusion In this paper, a positioning method combining depth learning with conventional image processing is proposed to solve the problem of empty yarn bobbin opening positioning when the yarn bobbin changing truss robot takes empty yarn bobbin from the yarn frame in the automatic production line of circular weft knitting machine. The improved Yolov5 model is adopted to frame the approximate position of the bobbin mouth, and then the information of the empty yarn bobbin mouth is obtained through image processing of conventional algorithms and ellipse contour fitting. The monocular camera ranging principle is adopted to locate the empty yarn bobbin mouth. The experiment proves that the improved model has smaller volume and higher accuracy, and the positioning result error is also within the allowable range, which basically meets the requirements of empty yarn bobbin positioning function of the yarn bobbin changing truss robot, providing a reference for the improvement and development of automatic yarn bobbin changing technology in the textile industry. © 2023 China Textile Engineering Society. All rights reserved.