Owing to the deficiency of pinhole imaging model, a method to measure the depth information of the object based on lens imaging principle is proposed in this paper. By drawing on the two states of the measured object before and after changing position, this method manages to adjust the position of lens until the image become clearest, record the related information of position variation in order to obtain the depth information of the object. Meanwhile, whether the lens central plane is parallel to the CCD plane or not is also discussed, which is the reason why the image is fuzzy. A new kind of two degrees of freedom parallel adjusting mechanism was designed to solve the two problems above, which can achieve two degrees of freedom including independent moving and independent rotating. The clearest image can be obtained by adjusting the object distance and the image distance without changing the focal length of the camera. Besides, the mechanism can also be used to detect whether the installation position of lens central plane matches the CCD plane or not.