Undistortion of the image giving an error
Show older comments
Hi,
I am trying to remove the distortion from the images but I am getting an error. I am using GOPro Hero 7 camera. Thing is whenever I used the checkerboard images from the same camera and only used the checkerboard image to remove the distortion from one of them images it removes the distortion but whenever I used the actual experimental image to remove the distortion from it I am getting the error shown below
Error:
Error using vision.internal.inputValidation.checkImageSize (line 14)
Image size is not consistent with camera intrinsics. It is likely that the image is not generated by
the specified camera.
Error in undistortImage (line 94)
vision.internal.inputValidation.checkImageSize(I, intrinsics.ImageSize);
Error in calibration3 (line 46)
[im, newOrigin] = undistortImage(imOrig, cameraParams, 'OutputView', 'full');
Code used: (This is one of the matlab example code I used)
%Create a cell array of file names of calibration images.
numImages = 12;
files = cell(1, numImages);
for i = 1:numImages
files{i} = fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', ...
'calibration', 'vfc', sprintf('image%d.jpg', i));
end
% Display one of the calibration images
I = imread(files{1});
%figure; imshow(I);
%title('One of the Calibration Images');
%Estimate Camera Parameters
% Detect the checkerboard corners in the images.
[imagePoints, boardSize] = detectCheckerboardPoints(files);
% Generate the world coordinates of the checkerboard corners in the
% pattern-centric coordinate system, with the upper-left corner at (0,0).
squareSize = 22; % in millimeters
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera.
imageSize = [size(I, 1), size(I, 2)];
cameraParams = estimateCameraParameters(imagePoints, worldPoints, ...
'ImageSize', imageSize);
% Evaluate calibration accuracy.
figure; showReprojectionErrors(cameraParams);
title('Reprojection Errors');
%Read the Image of Objects to Be Measured
imOrig = imread(fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', ...
'calibration', 'vfc', 'image25.jpg'));
figure; imshow(imOrig);
title('Input Image');
%Undistort the Image
% Since the lens introduced little distortion, use 'full' output view to illustrate that
% the image was undistored. If we used the default 'same' option, it would be difficult
% to notice any difference when compared to the original image. Notice the small black borders.
[im, newOrigin] = undistortImage(imOrig, cameraParams, 'OutputView', 'full');
figure; imshow(im);
title('Undistorted Image');
Accepted Answer
More Answers (0)
Categories
Find more on Calibrate Cameras in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!