1. An information processing apparatus comprising: a projection unit configured to project, onto a target object, a projection pattern that includes a measurement pattern for measuring a distance to the target object, and a code pattern for identifying the measurement pattern; a sensing unit configured to sense the target object onto which the projection pattern was projected; a change unit configured to change the projection pattern that is to be projected after the projection pattern onto the target object, on the basis of a relationship between the measurement pattern and the code pattern in a sensed image that was sensed by the sensing unit; an association unit configured to read out the code pattern in the sensed image of the target object onto which the projection pattern changed by the change unit was projected, and to associate the measurement pattern with the code pattern; and an acquisition unit configured to acquire, using the associated measurement pattern, a distance from the projection unit or the sensing unit to the target object.