Patent ID: 7885528

Claim:
A computer-implemented method for focusing a charge coupled device (CCD) lens on a selected surface of an object to be measured, the method comprising: obtaining an image of the object captured by the CCD lens of an image measuring machine; selecting a surface to be focused in the image of the object, and selecting a focus point and a focus range of the selected surface in the image; aligning a center of the CCD lens at a position of the focus point, and moving the CCD lens downwards by a first preset distance from a current Z-axis coordinate to approximate an estimate Z-axis coordinate of the CCD lens; moving the CCD lens upwards by a second preset distance from the estimate Z-axis coordinate, capturing a sequence of images of the object while the CCD lens moves upwards, and recording Z-axis coordinates of the CCD lens while capturing each of the sequence of images; calculating a definition of each captured image based on the focus point and the focus range; averaging the definitions of the captured images and the Z-axis coordinates of the CCD lens; creating a Z-D coordinate system based on the average definitions and Z-axis coordinates, sampling new Z-axis coordinates at a preset interval in the Z-D coordinate system, and calculating a new definition of each captured image based on the new Z-axis coordinates; calculating an accurate Z-axis coordinate of the CCD lens based on the selected surface, the new Z-axis coordinates and the new definition of each captured image; and moving the CCD lens to a position corresponding to the accurate Z-axis coordinate.