A camera provides an autofocus function by capturing a series of images
when a lens is at different positions, analyzing the images to identify a
best-focused image, and outputting the best-focused image. Unselected
images can be discarded. The camera can include a FIFO buffer that
receives image data from an image sensor as the image sensor captures
images. When a photographer activates a shutter button, an analysis
system, which may be implemented in software, analyzes the images in the
FIFO buffer and selects the best-focused image for output. In alternative
embodiments, the movement of the lens and the capture of the images can
be before or in response to activation of the shutter button.