In production processes that use surfacemount technology (SMT) for the assembly of printed circuit boards, automated optical inspection is widely employed to diagnose component defects. However, commonly used inspection algorithms can hardly meet reliability and time efficiency requirements simultaneously, especially when applied to the components of high-density and large-scale integration, such as ball grid array (BGA). In this paper, a novel approach is presented to inspect BGA component defects. An adaptive thresholding combined with modified (e,d)-component segmentation is first performed to extract the grayscale image of solder balls. A line-based-clustering method is then proposed to recognize ball array. Simultaneously, accurate position and orientation of BGA are obtained based on the recognition results. Finally, ball features are extracted to diagnose potential defects. The proposed algorithm is implemented on the host computer of Samsung SMT 482 machine. The results obtained show that the proposed approach is suitable for a vast majority of BGAs with different ball arrays and also that it is robust to interferences caused by the image segmentation. Furthermore, compared to Samsung's algorithm, it has significant advantages in time efficiency and high inspection accuracy under nonideal lighting conditions.