Aiming at the low efficiency of manual measurement of threads and the lack of practicability in machine vision measurement before, online size measurement of threads at the end of sucker rods based on machine vision was studied. A robotic arm is used to carry an optical device to achieve high-quality image acquisition of threads. Based on the prior knowledge of the thread profile angle, the directional edge detection operator is customized to achieve the accurate detection of the left and right edges of the thread. Noise filtering, sorting, and left and right edge-matching algorithms based on connected domains are developed to eliminate the interference effects of electrostatic dust and oil pollution in online measurement, and the dimension of thread profile angles, pitches, major diameters, and minor diameters can be precisely calculated. The experimental results show that the screw thread parameter measurement time is about 0.13 s; the maximum and minimum average errors of the thread angles are 0.011° and 0.632°, respectively; and the total average deviation is less than 0.08°. For the screw thread pitch, major diameter, minor diameter, and pitch diameter parameter measurement, the deviation of the measurement results between the proposed method and the universal tool microscope (UTM) method is less than 10 μm. It fully proves the effectiveness and accuracy of the method in this paper and, at the same time, shows that the method has good real-time performance and high application significance, which lays a good foundation for the subsequent online thread measurement.