In order to solve the problem of cylinder fitting, this paper proposes a method to fit the initial value more accurately. Using the characteristics of the cylinder data collected by laser displacement sensor, the point cloud data is first fitted in plane, then the original data points are projected, and the section where the axis is located is found. Then, a point passing through the axis and the axis direction vector are found out. In this way, the method is used to find out Find the initial value of the cylinder. Then, the particle swarm optimization algorithm is used to iterate with the initial value, and then the 7 parameters of the cylinder are calculated accurately, and the cylinder equation of point cloud data is obtained. The method can obtain accurate data when the cylinder fitting is used to find the initial value, which makes it difficult to find the optimal particle swarm optimization. Compared with commercial software SA, the radius error is less than 0.05mm. The experiment shows that the accuracy of the method meets the requirements of the field.