Problem with rectify StereoImages

20 visualizaciones (últimos 30 días)
MJ MJ
MJ MJ el 30 de Jul. de 2015
Respondida: David el 17 de Oct. de 2022
I want to do a 3D reconstruction from two images from the same camera. I used the Stereo Camera Calibrator App on Matlab R2015a in order to calibrate the camera. The calibration seems to work fine :
Then I used the example from the help to do the 3D reconstruction.
load('Param_test8.mat') % loads the camera parameters
% Read in the stereo pair of images.
I1 = imread('Cam1/Camera1_img1.tif');
I2 = imread('Cam2/Camera2_img1.tif');
% Rectify the images.
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams,'cubic','OutputView','full');
However, there is a problem when I run the rectifyStereoImages, since the two images are then positioned very far from each other :
I don't understand where the problem is, since the stereo calibration manages to position the cameras and the checkerboards very well. I tried different positions for the camera, and different images to reconstruct, but I don't know where the problem is.
  2 comentarios
Dima Lisin
Dima Lisin el 30 de Jul. de 2015
What happens if you press "Show Rectified" button in the Stereo Camera Calibrator app? Also, your reprojection errors are rather high. Generally, you want the mean error to be less than .5 of a pixel. It would help if you take more calibration images.
MJ MJ
MJ MJ el 30 de Jul. de 2015
When I press the button the following error shows :
Index exceeds matrix dimensions.
Error in vision.internal.calibration.CameraParametersImpl/getValidBounds (line 860)
boundaryPixelsUndistorted = boundaryPixelsUndistorted(:, [2,1]);
Error in vision.internal.calibration.CameraParametersImpl/computeUndistortBounds (line 785)
[xBounds, yBounds] = getValidBounds(this, undistortedMask, ...
Error in vision.internal.calibration.StereoParametersImpl/computeOutputBounds (line 377)
[xBoundsUndistort2, yBoundsUndistort2] = ...
Error in vision.internal.calibration.StereoParametersImpl/computeRectificationParameters (line 271)
[xBounds, yBounds] = computeOutputBounds(this, imageSize, ...
Error in vision.internal.calibration.StereoParametersImpl/rectifyStereoImagesImpl (line 190)
[H1, H2, Q, xBounds, yBounds] = ...
Error in rectifyStereoImages (line 99)
[rectifiedImage1, rectifiedImage2] = rectifyStereoImagesImpl(stereoParams, ...
Error in vision.internal.calibration.tool.StereoCalibrationImageDisplay/drawRectifiedImages (line 207)
[I1, I2] = rectifyStereoImages(I1, I2, stereoParams);
Error in vision.internal.calibration.tool.StereoCalibrationImageDisplay/drawBoard/drawRectifiedImagesCallback (line 71)
drawRectifiedImages(this, board, stereoParams);
Error in vision.internal.calibration.tool.ToggleButton/onPush (line 49)
this.PushedFcn();
Error in vision.internal.calibration.tool.ToggleButton>@(varargin)this.onPush(varargin{:}) (line 24)
'Tag', this.Tag, 'Callback', @this.onPush);
Error while evaluating UIControl Callback
I tried to add more images, but the error is still more than 1px, do you have any idea why that could be ? Thank your for your help

Iniciar sesión para comentar.

Respuestas (7)

Babak Zandi
Babak Zandi el 21 de En. de 2020
Editada: Babak Zandi el 21 de En. de 2020
Did anyone solve this issue?

Dima Lisin
Dima Lisin el 31 de Jul. de 2015
The error you are getting indicates a problem with calibration. rectifyStereoImages cannot compute the size of the rectified images, because the undistorted image gets folded upon itself. You definitely need more calibration images. Please be sure to get the checkerboard close to the edges and corners of the image, to get a better estimate of the distortion. Also, are you using 3 coefficients for radial distortion? If you are, then try using 2 instead.
  2 comentarios
MJ MJ
MJ MJ el 4 de Ag. de 2015
Thank you for your help. I tried to take more images, now there is no more error when I hit "ShowRectify", however the result seems strange. Besides I still have the same problem as before for rectifyimagestereo function.
Dima Lisin
Dima Lisin el 6 de Ag. de 2015
Can you move your cameras closer together to get more overlap of the field of view? If not, then you can try doing sparse reconstruction using the triangulate function, without having to rectify the images.

Iniciar sesión para comentar.


Wei Zhao
Wei Zhao el 5 de Jul. de 2016
Hi, i have the same Problem, have you solved it?

Wei Zhao
Wei Zhao el 5 de Jul. de 2016

Alois Sing
Alois Sing el 11 de Mayo de 2017
Editada: Alois Sing el 11 de Mayo de 2017

Hi, i have the same problem I cant move the cameras closer together, because i want a low distance error. I have 54 pictures of calibration pattern and the mean error is 0.1 pixel. The focal length is with around 150mm really high, because of the low distance error. It seems, that the problem is the function rectifyStereoImages.

If the outputview is "full" it shows the hole picture and the rectification is still good, but there is a big black space on each picture. calculating the disparity from this pictures is still hard and the result is really bad. On the picture below you can see the rectified pictures with horizontal lines witch shows, that the rectification process is still working.

and this is the best result from the disparity and the reconstructScene. The depth is too far away and a lot of points are on a plane.

If the outputview is "valid" it just shows the region, wich overlaps at infinity. You can see that on the left in the next picture, on the right is the "full" picture with the surroundet region wich is the output of "valid".

Can anybody help me with this problem ? Or has a hint for calculating the disparity from the "full" pictures.


kevin pierce
kevin pierce el 8 de Ag. de 2018
Same problem for me !

David
David el 17 de Oct. de 2022
I have the same problem, some solved this?

Categorías

Más información sobre MATLAB Support Package for USB Webcams en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by