Abstract:
An improved autofocus system and method that includes a controllable light source having at least two selectively activated substantially monochromatic output wavelengths adapted for illuminating an object; a camera receiving light from said light source reflected from a portion of said object and generating output signals responsive to said received light; a controller connected to said camera and said controllable light source for positioning said camera and sequentially illuminating a first portion of the object with at least two selectively activated substantially monochromatic output wavelengths, moving the camera to a second position and sequentially illuminating a second portion of the object with at least two selectively activated substantially monochromatic output wavelengths; and a data processor connected to said camera and receiving said output signals and for each portion, comparing the output signals associated with each wavelength and determining a focus parameter from said comparison

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    none 
       STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT 
       [0002]    none 
       THE NAMES OF THE PARTIES TO A JOINT RESEARCH AGREEMENT 
       [0003]    none 
         [0004]    INCORPORATION-BY-REFERENCE OF MATERIAL SUBMITTED ON A COMPACT DISC 
         [0005]    none 
       BACKGROUND OF THE INVENTION 
       [0006]    1. Field of the Invention 
         [0007]    This invention relates generally to image acquisition for automated systems and more particularly to an improved autofocus method and apparatus for such systems using a sequential multicolored illuminator. 
         [0008]    2. Description of Related Art Including Information Disclosed under 37 CFR 1.97 and 1.98 
         [0009]    Image acquisition systems commonly employ autofocus techniques to improve their effectiveness. A number of techniques has been employed in the past and while some of these have been effective to some extent, there is a need for improved apparatus and methods for autofocusing. While autofocusing systems and methods of the type described can be used to determine a focus position for a camera, they can also be used to measure surface features. 
         [0010]    Known systems conventionally employ top illumination to allow a camera to determine the peak contrast in a surface area during an auto focus sweep along an axis having a component perpendicular to the plane of the object, the Z-axis. The illumination may be created with light emitting diodes including colored light emitting diodes. Colored light emitting diodes are known to enhance the features of an object&#39;s surface because some features appear differently to a camera when using different colors for surface light. 
         [0011]    One known system analyzes small patches or tiles of pixels covering the entire video field of view (FOV). The system determines the focus Z-height, that is, the height perpendicular to the object, at which the object is in focus for each tile as the point in each tile at which the contrast is maximum for that tile. The map of the maximum contrast Z-heights at all locations in the field of view describes the topology of the surface. This data can be analyzed to give the shape of a cross-section anywhere on the surface, or to provide a focus height. 
         [0012]    Another system also uses contrast information to determine the location of the maximum Z-height in a tile and find the section shape of the area of objects. This system can link to the Z-height data from several field of view data sets from a number of auto focus sweeps together to analyze the form of object surfaces larger than one field of view. 
         [0013]    These known systems produce data with accuracy that depends on the characteristics of the surface being examined. When a tile size is small, for example 4×4 pixels, to obtain dense Z-height data from a surface, the structure of the surface can cause the data to become unreliable due in part to inherent camera noise and the surface reflectivity variation from tile to tile. 
       BRIEF SUMMARY OF THE INVENTION 
       [0014]    In accordance with one aspect of this invention an improved autofocus system and method includes a controllable light source having at least two selectively activated substantially monochromatic output wavelengths adapted for illuminating an object; a camera receiving light from said light source reflected from a portion of said object and generating output signals responsive to said received light; a controller connected to said camera and said controllable light source for positioning said camera at a first Z-axis position and sequentially illuminating a portion of the object with each of the at least two selectively activated substantially monochromatic output wavelengths and acquiring contrast information output signals, moving the camera to a second Z-axis position and sequentially illuminating the portion of the object with each of the at least two selectively activated substantially monochromatic output wavelengths and acquiring contrast information output signals; and a data processor connected to said camera and receiving said contrast output signals and comparing the output signals associated with each wavelength and determining a focus parameter from said comparison. 
         [0015]    It should be understood that as long as signals are acquired from more than one different color light source at each position, the precise order of illuminating the light sources and positions may be varied from that described. For example, in accordance with the invention a first light source of the first wavelength could be activated at a first position, a second light source at a second to wavelength activated at a second position and so on until all the light sources have been used. The order of light sources could then be repeated at the subsequent positions until signals from at least a two light sources had been obtained at substantially ail of the various Z-axis positions. It is the acquisition of signals from light sources of more than one wavelength at each position that provides improved accuracy, not any specific order of illumination or position. 
         [0016]    In accordance with another aspect of this invention each output signal comprises a gradient signal which is a function of the focus parameter for that position. 
         [0017]    In accordance with another aspect of this invention the focus parameter is a height parameter. 
         [0018]    In accordance with another aspect of this invention the output signal for each Z-axis position comprises a known wavelength dependant portion and a position dependant portion. 
         [0019]    In accordance with another aspect of this invention the data processor determines an average height based on the wavelength dependant portion and the position dependant portion for the at least two wavelengths. 
         [0020]    In accordance with another aspect of this invention the data processor determines a weighted average height based on the wavelength dependant portion and the position dependant portion for the at least two wavelengths. 
         [0021]    In accordance with another aspect of this invention the data processor determines an average height based on the wavelength dependant portion and the position dependant portion for the at least two wavelengths and disregards any output signal if the difference between the wavelength dependant portion and the position dependant portion for the at least two wavelengths is more than a predetermined amount. 
     
    
     
       BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWING(S) 
         [0022]      FIG. 1  is a diagrammatic view of a machine vision system implementing the autofocus apparatus and method of this invention; 
           [0023]      FIGS. 2   a - e  are a timing diagram illustrating the sequence of operation of the various elements of the invention; 
           [0024]      FIG. 3  is a flowchart showing the operation of the invention; 
           [0025]      FIG. 4  is a graphical representation of data produced by an autofocus system in accordance with this invention, along with data for a white (non monochromatic) source; 
           [0026]      FIG. 5  is a graphical representation of data produced by an autofocus system In accordance with this invention, with non-normalized contrast amplitudes. 
           [0027]      FIG. 8  is a graphical representation of wave length corrected focus peaks normalized In accordance with this invention. 
           [0028]      FIG. 7  is a graphical representation of contrast measurements of the three colors all taken at the same single Z-height. 
           [0029]      FIG. 8  is a graphical representation of the same three contrast measurements but shown with the previously gathered contrast curves. 
           [0030]      FIG. 9  is a graphical representation of the best fit process that then determines the best focus height. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0031]    Referring now to  FIG. 1 , a machine vision system indicated generally at  10  includes a camera  12  and a ring light  14  mounted on a platform  16  which is moveable along the Z-axis on slides  18  and  20  as shown by arrow  22 . Ring light  14  preferably has a central aperture through which images are acquired, surrounded by a multiplicity of LED&#39;s of different colors not visible. Ring light  14  includes an illumination source having selectively actuable, essentially monochromatic illuminators such as a plurality of LED&#39;s for sequentially illuminating an object  24  with monochromatic light sources of different wavelengths and, for making an autofocus scan along the Z-axis  22  to determine the position of maximum contrast for each wavelength and by combining them thereby to determine the position of the best focus. While the invention is described in accordance with an embodiment in which the camera moves along the Z-axis with respect to a fixed (with respect to the Z-axis) object, either the camera, the object, or both may be moved to change the Z-axis spacing between them. 
         [0032]    Those skilled in the art will understand that techniques for determining a focused position by maximizing contrast in an image are generally speaking known. A camera or other image acquisition device is directed to an area of interest within the field of view of the image acquisition device and the camera or other device is translated along an axis, referred to herein as the Z-axis and a plurality of image frames is captured at selected positions along the Z-axis. The frames are analyzed to determine a contrast value for such frame and the contrast values for the various frames are processed to determine a point on the Z-axis of maximum contrast from which the focus point can be determined. Methods for making such determinations from raw data are known and may be readily applied in accordance with this invention. It should be understood that there may not be an image for the point of maximum contrast, that point can be calculated from the contrast at other points. 
         [0033]    The invention enhances the autofocus process by sequentially or otherwise separately determining maximum contrast positions using a plurality of essentially monochromatic light sources of different colors. The invention provides an improved method of automatically focusing by virtue of the fact that different colors provide slightly different maximum contrast positions which may be combined to calculate a focus position that is more accurate than that produced by conventional white light or other polychromatic methods. 
         [0034]    While the invention preferably employs a plurality of monochromatic light sources and a single sensor, those skilled in the art will recognize that an analogous system employing a polychromatic light source and monochromatic sensors could also be used. For example, a polychromatic light source consisting of light emitting diodes of three colors such as red, green, and blue (RGB) and a camera sensitive to the same three colors may be employed. While such a light source might appear white to an observer, it is actually not since the spectrum is limited to the three wavelengths and very little power is produced between those wavelengths. A genuinely white light source could conceivably be employed but the small percentage of power generated in the specific wavelengths to which the camera is responsive would require that the total power of the white light source be a higher than desirable in order to obtain a suitable response in the camera. Typically, light emitting diodes have relatively narrow bandwidths, on the order of 10 to 15 nm and cameras are available that are responsive to the same wavelengths. While red, green, and blue light emitting diodes are commonly available and cameras with similar responses are likewise available, it will be understood that these particular colors are not required by this invention, any combination of illumination sources and similarly responsive cameras may be used. In such a system, the three colors of illumination sources would be energized simultaneously and the camera would be arranged to provide separate outputs at each responsive wavelength. This would both simplify synchronization requirements and allow higher-speed capture of light from the illumination sources and consequently higher speed determination of the point of maximum contrast. 
         [0035]    While it is possible to acquire an arbitrarily large number of images as the camera is translated along the Z-axis in autofocus scan path, the point of maximum contrast from which the focus point may be determined can be calculated to a suitable accuracy from a limited number of discrete points along the path. It is not necessary that an image be acquired at the point of maximum contrast in order for that point to be determined. 
         [0036]    Moreover, while the present embodiment of the invention describes a system in which a single focus position is determined for an object, the invention may also be employed to determine multiple focus positions corresponding to different locations on the object when the surface of the object contains height variations sufficient to require multiple focus points. 
         [0037]    Preferably, in accordance with the invention, the surface is illuminated with top light to permit the camera to determine the peak contrast in the surface during the autofocus sweep. Light emitting diodes are preferably employed as light sources because they are nearly monochromatic and produce a very narrow wave length band of light. Different color LEDs enhance features on the surface of the object because some features appear differently to the camera when using different colors of surface light. It will be understood that the illuminator may include a plurality of LED&#39;s of each color. 
         [0038]    In accordance with one aspect of this invention, the camera  12  includes imaging optics  13  that relay an image of the surface to the camera&#39;s sensor, preferably a pixilated sensor such as a CCD sensor. The optics are designed to focus different colors, that is different wave lengths of light, at different distances from the objective lens. This is sometimes referred to as chromatic aberration, and in many applications is undesirable and is corrected. In accordance with this invention it is used advantageously. Thus, for each color of LED that illuminates the surface, the height where maximum contrast is found during an autofocus sweep is a different absolute height. Because the lens can be designed to focus each wavelength at a different Z-height the Z-height offset for each color is fixed and known for each lens design. These offsets can be precisely determined. It is the combination of this offset and the Z-axis location of the point of maximum contrast that is used to determine the location of the actual maximum contrast point. As the camera moves along the Z-axis in an autofocus sweep, the locations where maximum contrast occurs for each color are different but because the offsets are known, the actual location of the point of maximum contrast can be calculated for each color. 
         [0039]      FIG. 2  is a timing diagram and  FIG. 3  is a flowchart which together describes the operation of the autofocus system in accordance with this invention. 
         [0040]    The process begins at block  40  when the camera is moved to the start of the autofocus scan pass. The autofocus motion, preferably either an upward or a downward motion of the camera along the Z-axis is then initiated at block  42 . When the camera reaches a first autofocus capture position at block  44  a counter is checked at  46  to determine whether all of the colors have been used. If not, the process waits for the end of the current camera frame, see  FIG. 2   a , the light is set to the first color at box  50  and  FIG. 2   c  and an image is acquired at box  52  and  FIG. 2   b . The contrast values are then computed from the image just acquired at box  54 . The process then repeats for each of the plurality of colors as shown in  FIGS. 2   d  and  2   e  until all of the colors have been used at which point a comparison is made at box  56  to determine whether the last capture position has been reached. If not, the Z-axis position is moved and the portion of the process described in connection with blocks  46 ,  48 ,  50 ,  52  and  54  is repeated until the last capture position has been reached at which point the maximum contrast position for each color is calculated at block  58  and the information from all of the colors is combined to produce a final focus height determination at box  60 . 
         [0041]    Each color LED Is activated as shown in  FIGS. 2   c ,  2   d , and  2   e  for a time long enough for the camera to gather the required charge as shown in  FIG. 2   b  to determine the intensity gradient. Preferably, three colors, for example red, green, and blue are used but illuminators with only two colors may also be used and provide an improvement over known autofocus apparatus. 
         [0042]    As shown in  FIG. 4 , each of the colors produces normalized output curves  70 ,  72  and  74  having contrast peaks at different absolute positions  90 ,  92  and  94  along the Z-axis.  FIG. 4  shows the peaks for red  70  green  72  and blue  74  illumination sources respectively along with a somewhat broader peak produced by a white illumination source  78  for reference. It can he seen that the points of maximum contrast for each color may be determined substantially more precisely by use of multiple monochromatic light sources in accordance with this invention. 
         [0043]      FIG. 5  shows the raw focus curves for the three colors without normalization on a single axis demonstrating the differences in position as well as the differences in amplitude produced in accordance with the invention.  FIG. 6  shows the outputs for the red  70 , green  72  and blue  74  illuminators. 
         [0044]      FIG. 6  shows the same data as in  FIG. 4  but with the Z-axis positions corrected for the chromatic aberration of the imaging lens so that only actual the deviation of the peaks from the reference position caused by contrast differences at the different wavelengths is shown. The computed best focus position  88  is shown. 
         [0045]    While the invention contemplates acquiring contrast information at a plurality of discrete points along the Z-axis, the Z-axis motion can be continuous or substantially continuous and the color of the illuminators can be changed at each new camera frame of data until the camera has moved far enough along the Z-axis to go through and beyond the position of maximum contrast. This method produces data relatively quickly. 
         [0046]    Alternatively, the Z-axis motion can be a stepwise motion starting above or below the position of maximum contrast and the color of the illuminators can be changed so that all colors are used for each step in the Z-axis motion. Movement is continued until the camera has stepped through and beyond the position of maximum contrast. This method also produces data relatively quickly. 
         [0047]    The Z-axis motion can be a series of continuous sweeps along the Z-axis each focusing on the same region of interest on the surface, with each sweep using a different color of illumination. This method is easier to implement than the preceding methods because the illumination change does not need to be synchronized with the camera frame capture, each color light can simply be left on during the sweep, but this is somewhat slower. 
         [0048]    In accordance with another aspect of the invention, illumination sources producing at least three colors of light are provided together with an objective lens having sufficient chromatic aberration so that the positions of maximum contrast for the three colors of light are displaced from one another by the chromatic aberration of the lens system. In this case, if the depth of field of the optics is selected appropriately, the position of maximum contrast and therefore the appropriate autofocus position can be obtained without moving the camera or the object during image acquisition. In accordance with a further embodiment of the invention the data processor determines an average height based on the wavelength dependant portion and the position dependant portion for the at least two wavelengths and disregards any output signal if the contrast is below a predetermined amount. 
         [0049]    In accordance with a still further embodiment of the invention, the data processor determines an average height based on the wavelength dependant portion and the position dependant portion for the at least two wavelengths and disregards any output signal if the intensity of the output signal for one of the wavelengths is below a predetermined magnitude. 
         [0050]    Finally, in accordance with a variation on the embodiment already described, the Z-axis position can be stationary while the color of the illumination is changed to cause different portions of the region of interest on the surface to be at best focus at a different Z-height for each color as determined by the optical design. The contrast measurements for each of the three colors at the fixed position are represented in  FIG. 7  by  102  (red),  104  (green) and  106  (blue).  FIG. 8  shows these same contrast measurements represented with the contrast curves previously found in  FIG. 5 . Z-position  112  represents the single Z-position that the contrast measurements were taken at. Focus curves  70 ,  72  and  74  represent the nominal focus data as found from  FIG. 6 .  FIG. 9  shows the focus curve displacement found after a best fit is taken to superimpose the contrast values  102 ,  104  and  106  with the nominal focus curves  70 ,  72  and  74 . Offset distance  118  is the Z-displacement from the position where the were images taken to the position where the best focus position is found. Thus, as long as the single fixed position is sufficiently close to the maximum contrast position the actual maximum contrast position can be determined quickly and without moving the camera. 
         [0051]    It should be noted that the relative heights and order of the colors are arbitrarily depicted. The actual displacements of the different colors best focus position are dependent on the optics design and this will not necessarily put them in relative order of wavelength. 
         [0052]    In accordance with this method, it is possible for more than one color source to be activated simultaneously by using a color camera so that the position of maximum contrast can be determined separately for each color from a single frame. 
         [0053]    Although the invention has been described with reference to the embodiments described above, it will be evident that other embodiments may be alternatively used to achieve the same object. The scope of the invention is therefore not limited to the embodiments described above, but may also be applied to other applications where either focus distance or the height of surface features must be determined. 
         [0054]    It should further be noted that the term “comprises/comprising” when used in this specification, including the claims, is taken to specify the presence of stated features, integers, steps or components, but does not exclude the presence or addition of one or more other features, integers, steps, components or groups thereof. It should also be noted that the word “a” or “an” preceding an element in a claim does not exclude the presence of a plurality of such elements. Moreover, any reference signs do not limit the scope of the claims; the invention may be implemented by means of both hardware and software, and several “means” may be represented by the same item of hardware. As used herein the term color is not intended to be limited to visually perceptible colors. Furthermore, the invention resides in each and every novel feature or combination of features.