1. A method for depth mapping, comprising: receiving in a digital processor an image of a pattern of spots that has been projected onto a scene, which includes a hand having fingers; processing the image in order to segment and find a three-dimensional (3D) location of the hand; based on the spots appearing on the hand in the 3D location, computing a first depth value that is characteristic of the hand and a second depth value that is characteristic of a background of the scene behind the hand, and sorting the spots in a vicinity of the hand in the image between the first and second depth values in order to extract separate, respective contours of each of the fingers; and processing the respective contours in order to identify a posture of the hand and fingers.