1. An information processing apparatus for generating a projection pattern used in three-dimensional measurement of a target object, comprising: a determination unit configured to determine a projection code string for generating the projection pattern based on distance information of the target object which is obtained in advance; and a generation unit configured to generate a pattern image of the projection pattern based on a projection code string determined by said determination unit.