| Algorithm 1. MATLAB pseudocode to calculate the rigid transformation between two 3D scanning systems from a pair of 3D checkerboard captures. |
| Pc2 %point cloud from capture of 3Dcb from system 2 pc1_ref %point cloud from system 1 (reference coordinate system) function Checkerboards3d_estimateT(pc2, pc1_ref) % remove background pc2_noBackground = abs(pc2-distEstimation) <= eps pc1_noBackground = abs(pc1_ref-distEstimation) <= eps for pc = pc2_noBackground, pc1_noBackground do % fit plane, do PCA to transform from 3D into 2D planeModel = pcfitplane(pc) [pcaPlane,coeff,mu] = pca(planeModel) % create regular binary grid for [x,y] = min(pcaPlane):resolution:max(pcaPlane) point_nn = findNearestNeighbors(pcaPlane, [x,y], 1) if abs(point_nn-[x,y])>resolution zGrid(x,y) = 1 end if end for % detect connected components (holes) CC = bwconncomp(zGrid) % calculate median coordinates of holes, sort them and % use inverse PCA to transform back into 3D Median_cc = median(CC) holeMedians = sort(Median_cc) holeMedians3D = holeMedians * transpose(coeff) + mu end for % estimate the geometric transformation between hole medians from both checkerboards tFormEst = estimateGeometricTransform3D(holeMedians3D_2, holeMedians3D_1,’rigid’) return tFormEst end function |