There is a new Raspberry Pi Camera Module 3 available with autofocus and a focus range 5cm to infinite. Should be able to do the job using the python Picamera2 library.

Read More...