system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: how does the autofocus work in a DSLR camera?

I know it's something related to the camera changing the focal length until it obtains the sharpest image but does it know which one is the sharpest image?
gpt
It evaluates the sharpness by edge detection.  It finds the line that divides the highest brightness and color change, then changes the focus to  create the sharpest, most abrupt change across the line.  They get more sophisticated by testing several areas and more recently, prioritizing face detection.