-1

The rectification function in Matlab seems to be responding wrong. Can anyone let me know if I am getting the right output?

Left Image Right Image Anaglyph of unrectified images Anaglyph of rectified images

Here is my code:

leftImageSnapshot = getsnapshot(handles.vidL);
imshow(leftImageSnapshot);

rightImageSnapshot = getsnapshot(handles.vidR);
imshow(rightImageSnapshot);



[I1Rect,I2Rect]=rectifyStereoImages(I1,I2,stereoParams,'OutputView','valid');
    imshowpair(I1Rect,I2Rect,'falsecolor','ColorChannels','red-cyan');

I was following this link for image rectification. After rectification, the images are supposed to look like the cameras are parallel. But in my case, the vertical disparity still exists in the image.

I am trying to obtain a disparity map for which the vertical disparity should be removed.

Aakaash Jois
  • 288
  • 4
  • 17
  • 1
    Your question is if, just looking at 2 pictures, we can say if they are right or wrong? No, we cant. You need to tell us: what code you used, why you think is wrong, how a rigth image would look like. – Ander Biguri Apr 26 '16 at 10:07
  • Quoting the help "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [mcve] " – Ander Biguri Apr 26 '16 at 10:08
  • I have updated the question with more information and a link with shows how the rectified image should look like – Aakaash Jois Apr 26 '16 at 10:23
  • The parameters are 100% dependant on `stereoparams`, obviously. However, there is no information on this post about `stereoParams`. – Ander Biguri Apr 26 '16 at 11:22
  • [Here](https://www.dropbox.com/s/ioe1vtye8dx2de9/stereoParams.mat?dl=0) is my stereoParams file. I used the inbuilt Stereo Camera Calibration Tool to calibrate the cameras and got that stereoParams file. – Aakaash Jois Apr 26 '16 at 11:35

1 Answers1

1

My best guess would be that your cameras were moved after you did the calibration. Once you calibrate, the position and orientation of the cameras relative to each other cannot change. If it does, your stereoParams are no longer valid.

To see what went wrong, do the calibration again using the Stereo Camera Calibrator app, and then click "Show Rectified" button at the lower left corner of the main image pane. I will show you a rectified pair of calibration images. If those look ok, then your cameras have moved and you have to take the calibration images again and recalibrate. If the rectified calibration images look bad, then something is wrong with your calibration.

By the way, there is a stereoAnaglyph function, which you can use to create a red-cyan anaglyph.

Dima
  • 38,860
  • 14
  • 75
  • 115
  • I'll calibrate it again and check it out. It won't be a problem if both the cameras move together right? I am planning to mount this setup on an RC Vehicle – Aakaash Jois Apr 26 '16 at 15:31
  • If they are fixed relative to each other, you should be ok. But from looking at your image, I would guess that they bounce up and down. Definitely try rectifying the calibration images first. – Dima Apr 26 '16 at 15:33
  • Thank you. It's definitely better after recalibrating. I'll try to fix it better to stop it from moving relative to each other. – Aakaash Jois Apr 26 '16 at 15:47