1. An information processing apparatus for generating a projection pattern used in three-dimensional measurement of a target object, the information processing apparatus comprising: an obtaining unit configured to obtain first distance information of the target object based on a first image obtained by capturing the target object onto which a first projection pattern is projected and to obtain second distance information of the target object based on a second image obtained by capturing the target object onto which a second projection pattern is projected, wherein the first projection pattern is generated based on a first projection code string and the second projection pattern is generated based on a second projection code string; a determination unit configured to determine a projection code string for generating a projection pattern to be projected based on the first distance information and the second distance information; a generation unit configured to generate a pattern image of the projection pattern to be projected based on a projection code string determined by the determination unit; an image capturing unit configured to capture the target object on which the pattern image is projected and to obtain an image; a pattern obtaining unit configured to extract a captured pattern from the image to obtain a captured code string; an association unit configured to collate the projection code string with the captured code string to perform association between the projection code string and the captured code string; and a measurement unit configured to measure distance information of the target object based on the association, wherein the determination unit determines the projection code string based on the difference between a distance value indicated by the first distance information and a distance value indicated by the second distance information.