Undistortion of the image giving an error

조회 수: 30 (최근 30일)
muhammad choudhry
muhammad choudhry 2020년 9월 28일
댓글: Ashwani gulati 2021년 10월 6일
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');

채택된 답변

Nitin Kapgate
Nitin Kapgate 2020년 10월 7일
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
Ashwani gulati
Ashwani gulati 2021년 10월 6일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Camera Calibration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by