Undistortion of the image giving an error

31 visualizaciones (últimos 30 días)
muhammad choudhry
muhammad choudhry el 28 de Sept. de 2020
Comentada: Ashwani gulati el 6 de Oct. de 2021
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');

Respuesta aceptada

Nitin Kapgate
Nitin Kapgate el 7 de Oct. de 2020
The size of image you are trying to undistort is different from the size of images used for estimating the camera calibration parameters. The camera parameters are being estimated from the inbuilt MATLAB calibration images.
In order to use the the undistortImage function to remove distortion from the images captured by your GoPro camera, you will need to estimate the camera intrinsics, extrinsics, and lens distortion parameters using the calibration images taken by your camera.
You can use thisworkflow to calibrate your camera using the Camera Calibrator App.
  1 comentario
Ashwani gulati
Ashwani gulati el 6 de Oct. de 2021
Hello,
I have used stereo camera calibrator but still it's giving my this 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 rectifyStereoImages (line 126)
vision.internal.inputValidation.checkImageSize(I1, stereoParams.CameraParameters1.ImageSize);
Error in Depthestimationfromstereovideolenovocameratest5 (line 54)
rectifyStereoImages(frameLeft, frameRight, stereoParams);
could you please help me with this?

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by