user1809923
user1809923

Reputation: 1255

Reproducing Camera Reprojection Error

I loaded some images into the camera calibration app and exported the resulting camera parameters into a structure called "oldCameraParams". What I want to do now is to reproduce the reprojection error for one of the images used during calibration. I aim to do this like this:

I = imread(imagePath);
[imagePoints,boardSize] = detectCheckerboardPoints(I);
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
squareSize = 30; 
camMatrix = cameraMatrix(oldCameraParams,oldCameraParams.RotationMatrices(:,:,1),oldCameraParams.TranslationVectors(1,:));
projectedPoints = [worldPoints zeros(size(worldPoints,1),1) ones(size(worldPoints,1),1)] * camMatrix;
projectedPoints = bsxfun(@rdivide,    projectedPoints(:,1:2),projectedPoints(:,3));
euclideanDistances = sqrt(sum((imagePoints - projectedPoints) .^2, 2));
meanReprojErrors(ii) = mean(euclideanDistances);

I should use the exact same parameters (camera intrinsics, rotation matrix and translation vector) but still my projectedPoints are different than the ones created during calibration and therefore my meanReprojErrors is higher. Any idea why?

Upvotes: 1

Views: 568

Answers (1)

Dima
Dima

Reputation: 39389

You are getting different reprojection errors, because you are not accounting for distortion. If you call undistortImage before calling detectCheckrboardPoints, then you should get values that are closer to the reprojection errors computed during calibration.

Upvotes: 1

Related Questions