摘要 |
A method for measuring distance includes: obtaining an image of an object and detecting whether the image of the object is clear when a camera module is initialed to capture the image of the object; controlling a lens to move along a center axis of the lens barrel when detecting the image of the object is not clear, and controlling the lens to stop moving when detecting the image of the object is clear; obtaining an image distance variation, and calculates a current image distance according to the image distance variation and a initial image distance; calculating a current object distance according to the current image distance, a focal distance, and a formula 1/u=1/f-1/v, wherein, u is the current objection distance, f is the focal distance, v is the current image distance. |