1. A method for three-dimensional mapping, comprising: providing a mapping device, which comprises: a projector configured to project a pattern onto an object; a first image sensor, which has a first optical characteristic and is configured to capture images of the object on which the pattern is projected; a memory configured to store a reference image of the pattern; and a processor configured to measure shifts in the pattern in the images relative to the stored reference image in order to generate a three-dimensional (3D) map of the object; generating the reference image in a production facility by: operating the mapping device so as to project the pattern onto a reference surface, prior to projecting the pattern onto the object; capturing a second image of the pattern on the reference surface using a second image sensor, which is external to and separate from the mapping device and has a second optical characteristic that is enhanced relative to the first optical characteristic; and registering the first and second images to produce the reference image, which is registered in a frame of reference of the projection and imaging device, wherein registering the first and second images comprises identifying and correlating features common to the first and second images in order to find local transformations, and then combining the local transformations to apply a global transformation to the second image in order to produce the reference image; storing the reference image produced by registering the first and second images in the memory of the mapping device; and generating the 3D map using the mapping device by projecting the pattern onto the object, capturing the images of the object using the first image sensor, and measuring the shifts in the pattern relative to the stored reference image.