|
发表于 2008-12-12 18:38:00
|
显示全部楼层
Algorithm:
The auto focus algorithm implemented in the sensor firmware seeks to maximize
sharpness of vertical lines in images output by the sensor, by guiding an external lens
actuator to the position of best lens focus. The algorithm is actuator-independent,
providing guidance by means of an abstract 1-dimensional position variable, leaving the
translation of its changes into physical lens movements to a separate AF mechanics
(AFM) driver.
For measuring line sharpness, the AF algorithm relies on focus measurement engine in
the color pipeline, which is a programmable vertical-edge-filtering module. The module
convolves two preprogrammed 1-dimensional digital filters with luminance (Y) data it
receives row by row from the color interpolation module. In every interpolated image,
the pixels whose Y values are used in the convolution form a rectangular block that can
be arbitrarily positioned and sized, and in addition divided into up to 16 equal-size subblocks,
referred to as AF windows or zones. The absolute values of convolution results
are summed separately for each filter over each of the AF windows, yielding up to 32
sums per frame.
There are several motion sequences through which the MT9D112 AF algorithm can
bring a lens to best focus position. All these sequences begin with a jump to a preselected
start position, for example, the infinity focus position. This jump is referred to asthe first flyback. It is followed by a unidirectional series of steps that puts the lens at up
to 19 preselected positions different from the start position. This series of steps is called
the first scan.
During the scan, the AF algorithm stops the lens at each preselected position long
enough to obtain valid sharpness scores. The normalized score for each AF window is
stored along with information on how many zones had a high sharpness score and the
position with the maximum sharpness score is determined taking into account the zone
information. This way the algorithm can handle scenes with objects at different
distances.
After the first scan, the AF algorithm provides a number of ways to proceed with final
lens positioning. The user should select a way that best fits the magnitude of lens actuator
hysteresis and desired lens proximity to the truly optimal position. Actuators with
large, unknown or variable hysteresis should do a second flyback and either jump or
retrace the steps of the first scan to the best scanned position. Actuators with constant
hysteresis (like stepper motors) can be moved to that position directly from the end
position of the scan-the AF algorithm offers an option to automatically increase the
length of this move by a preprogrammed backlash-compensating step. Finally, if the first
scan is coarse relative to the positioning precision of the lens actuator and depth of field
of the lens, an optional second fine scan can be performed around the lens position
voted best after the first scan. This second scan is done in the same way as the first,
except that the positions it covers are not preselected. Instead, the AF algorithm user
must set step size and number of steps for the second scan. The second scan must be
followed by the same hysteresis-matching motion sequence as the first scan, for
example, a third flyback and jump to the best position.
The AF driver is disabled on power-up. If AF is desired, it must be explicitly enabled after
every power up or reset before it can be used. This can be accomplished by:
Establish AF motor type
• set afm.type (0x002) = 129 (for helimorph AF)
afm.type (0x002) = 130 (for stepper motor AF)
afm.type (0x002) = 131 (for AD5398)
• turn on AF in preview mode seq.previewPar.af=1
• call "refresh" sequencer command seq.cmd=5 |
|