1. A method of automatically focusing a projector in a projection system, the method comprising: projecting, by the projector, a pre-determined hierarchical binary pattern on a projection surface; capturing an image of the projected pre-determined hierarchical binary pattern by a camera synchronized with the projector; resizing the captured image to a resolution used to form the pre-determined hierarchical binary pattern; computing a depth map from the resized captured image and the predetermined hierarchical binary pattern down-sampled to the resolution; and adjusting a focus of the projector based on the computed depth map.