- The calibration images that you used to calibrate the camera.
- The calibration results that you got (in a MAT file).
- Link to spec sheet of the camera that you are using.
Disparity map from stereo vision not accurate
30 次查看(过去 30 天)
显示 更早的评论
I have a problem trying to do depht axtraction from a stereo vision system.
I'm using two cameras (iDS, no RGB but B&W images) with two different optics both with the same focal lenght (8 mm).
After the calibration done with the 'stereo camera calibrator' app from Matlab the result was an overall mean error of 0.32 pixels.
Then I took these photos of an object with both cameras:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1444527/image.png)
and I tried to obtain the disparity map with this code:
left=imread('spinaleft.png');
right=imread('spinaright.png');
figure
imshowpair(left,right,"montage")
%% rectification
[leftRect,rightRect,reprojectionMatrix]=rectifyStereoImages(left,right,stereoParams2607);
figure
A=stereoAnaglyph(leftRect,rightRect);
imshow(A)
%% disparity
leftRect=im2gray(leftRect);
rightRect=im2gray(rightRect);
disparityRange = [0 432];
disparityMap = disparityBM(leftRect,rightRect,'DisparityRange',disparityRange,'UniquenessThreshold',10,'BlockSize',9,'ContrastThreshold',0.5);
figure
imshow(disparityMap,disparityRange)
title('Disparity Map')
colormap jet
colorbar
but unfortunately the disparity map is too different from the reality. This was the best one I've got:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1444532/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1444537/image.png)
I really don't understand what I'm doing wrong, and I have some doubts:
1) could it be better if I use RGB photos instead of B&W photos?
2) why there's a blue area in the left side of the disparity map?
3) why are the windows in red? It looks like the system sees them closer than they are.
Thanks for helping me!
2 个评论
Giridharan Kumaravelu
2023-7-28
I don't think the results are poor because they are B&W photos. There might have been something gone wrong during the calibration process. Could you share the following for a deeper investigation?
采纳的回答
VINAYAK LUHA
2023-9-1
Hi Luca,
As per my understanding, the result is decent given the camera calibration accuracy and the use case scenario. However, the following suggestions may help to enhance the result quality.
1.Improvement in the camera calibrations
- In the images used for calibration the pattern should be at a distance roughly equal to the distance from the camera to the object of interest with auto-focus disabled.
- Ensure that the region of interest is fully visible from both cameras of the stereo camera pair.
2. Image post-processing
- Consider applying Morphological transformation such as dilation or smoothing using gaussian blurr to the disparityMap.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1471006/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1471011/image.png)
To address your questions
- Yes, colour variations in RGB images can help in distinguishing objects or surfaces with similar intensities in grayscale (B&W) and can provide depth cues in certain scenarios.
- The disparity of pixels which are less unique or less textured are unreliable and are marked as "nan" by the block matching algorithm which manifests as the blue area on the left of the disparityMap.
- To improve the results, consider implementing the suggestions mentioned above, such as refining the camera calibration and exploring post-processing techniques.
Here are the articles you may find helpful for your references:
- Best practices to prepare camera and capture images for “stereo vision camera calibration app” https://in.mathworks.com/help/vision/ug/prepare-camera-and-capture-images.html
- MATLAB documentation of “disparitybm” function https://in.mathworks.com/help/vision/ref/disparitybm.html [KA6] [VL7]
- MATLAB documentation on Morphological filtering https://in.mathworks.com/help/images/morphological-filtering.html
I hope it helps!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Support Package for USB Webcams 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!