extrinsics test1

Contents

load image filenames and prior calibration

clear
close all
load filelist
load params2

cameraParams
cameraParams = 

  cameraParameters with properties:

   Camera Intrinsics
                    IntrinsicMatrix: [3x3 double]
                        FocalLength: [6.5732e+03 6.5686e+03]
                     PrincipalPoint: [2.3784e+03 1.4077e+03]
                               Skew: 0

   Lens Distortion
                   RadialDistortion: [0.0099 -0.0836]
               TangentialDistortion: [0 0]

   Camera Extrinsics
                   RotationMatrices: [3x3x12 double]
                 TranslationVectors: [12x3 double]

   Accuracy of Estimation
              MeanReprojectionError: 0.5275
                 ReprojectionErrors: [64x2x12 double]
                  ReprojectedPoints: [64x2x12 double]

   Calibration Settings
                        NumPatterns: 12
                        WorldPoints: [64x2 double]
                         WorldUnits: 'in'
                       EstimateSkew: 0
    NumRadialDistortionCoefficients: 2
       EstimateTangentialDistortion: 0

choose which image

n = 15;
filename = files{n};
rgb = imread(filename);

Undistort image

im = undistortImage(rgb, cameraParams);
sz = size(im);
imshow(imresize(im,800/sz(2)));

Detect checkerboard corners

Generate the world coordinates of the checkerboard corners in the pattern-centric coordinate system, with the upper-left corner at (0,0).

[imagePoints, boardSize] = detectCheckerboardPoints(im);
Warning: The checkerboard must be asymmetric: one side should be even,
and the other should be odd. Otherwise, the orientation of the board
may be detected incorrectly. 

Generate world coordinates

squareSize = 3; % in inches
worldPoints = generateCheckerboardPoints(boardSize, squareSize);

show points

show_points(im,imagePoints,worldPoints);
Warning: Image is too big to fit on screen; displaying at 25% 

Compute new extrinsics

[R, T] = extrinsics(imagePoints, worldPoints, cameraParams);

Compute vector from target to camera (in feet)

loc = -T*R'/12

fprintf('camera is %g ft above floor\n',-loc(3));
loc =

    7.0859   -4.3194   -4.7078

camera is 4.70778 ft above floor