How does the camera know (measure) what the distance is to the object?
Modern cameras use a variety of techniques to find the distance to objects. Some cameras bounce sound off of the objects and time how long it takes for the echo to return. Others observe the central portion of the image (presumably the object) from two vantage points simultaneous and then adjust the angles at which those two observations are made until the images overlap. This rangefinder technique is the one you use to sense distance with your eyes. You view the object through each eye and adjust the angles of view until the two images overlap (in your brain). At that point, you can tell how far away the object is by how crossed or uncrossed your eyes are. A rangefinder camera has two small viewing windows and lenses to look at the object, just as you have two eyes to look at the object. Finally, some cameras don’t really measure the distance to the object but instead adjust the lens until it forms the sharpest possible image. A sharp image has the highest possible contrast while an out-of-focus image will have relatively low contrast. The cameras adjust the lens until the light striking a sensor exhibits maximal contrast (brightest bright spots and darkest dark spots).