www.gusucode.com > vision 源码程序 matlab案例代码 > vision/SingleCameraCalibrationExample.m

    %% Single Camera Calibration
% Create a set of calibration images.
images = imageSet(fullfile(toolboxdir('vision'),'visiondata',...
            'calibration','fishEye'));
imageFileNames = images.ImageLocation;
%%
% Detect the calibration pattern.
[imagePoints, boardSize] = detectCheckerboardPoints(imageFileNames); 
%%
% Generate the world coordinates of the corners of the squares.
squareSizeInMM = 29;
worldPoints = generateCheckerboardPoints(boardSize,squareSizeInMM); 
%%
% Calibrate the camera.
params = estimateCameraParameters(imagePoints,worldPoints);
%%
% Visualize the calibration accuracy.
showReprojectionErrors(params);
%%
% Plot detected and reprojected points.
figure; 
imshow(imageFileNames{1}); 
hold on;
plot(imagePoints(:,1,1), imagePoints(:,2,1),'go');
plot(params.ReprojectedPoints(:,1,1),params.ReprojectedPoints(:,2,1),'r+');
legend('Detected Points','ReprojectedPoints');
hold off;