space = 5; % The distance from one line to the next, in our calibration grid, is 5 cm. rigN = 10; % We have a 10*10*10 grid. [A2,A1] = meshgrid(0:space:space*rigN,space:space:space*rigN); A1 = im2col(A1,[1,1]); A2 = im2col(A2,[1,1]); A3 = zeros(1,rigN*(rigN+1)); I = ones(1,rigN*(rigN+1)); objectpoints1 = [A1; A2; A3; I]; % Object points on one plane of the grid. objectpoints2 = [A3; A1; A2; I]; objectpoints3 = [A2; A3; A1; I]; orig = [0 0 0 1]'; % All corner points on the grid as in defined world coordinate system. AllObjectPoints = [objectpoints1 objectpoints2 objectpoints3 orig]; % Example corner points to be used in calibration. P =[ 0 0 0 0 5 45 5 45 5 45 5 45; 45 45 5 5 45 45 5 5 0 0 0 0; 45 5 45 5 0 0 0 0 5 5 45 45; 1 1 1 1 1 1 1 1 1 1 1 1 ];