Clear Filters
Clear Filters

Reconstructing 3D from two stereo images

5 views (last 30 days)
I am trying to reconstruct 3D from two stereo grayscale images. The reason im using grayscale because it show vein's depth. But the disparity map and pointcloud doesn't show much information from images. Here the code
clc
clear all
close all
load('handshakeStereoParams.mat');
I1 = im2double(imread('back_left_10_n1.png'));
I2 = im2double(imread('back_right_10_n1.png'));
[G1, G2] = rectifyStereoImages((I1),(I2),stereoParams);
A = stereoAnaglyph(G1,G2);
figure
imshow(A)
title('Red-Cyan composite view of the rectified stereo pair image')
imshow(cat(3,A),'InitialMagnification',50);
disparityMap = disparity(im2gray(G1),im2gray(G2)) ;
figure
imshow(disparityMap,[0 64],'InitialMagnification',50);
title('Disparity Map');
colormap jet
colorbar
points3D = reconstructScene(disparityMap, stereoParams);
% Convert to meters and create a pointCloud object
points3D = points3D ./ 500;
ptCloud = pointCloud(points3D,"Intensity",G2);
% Create a streaming point cloud viewer
player3D = pcplayer([-1, 2], [-1, 2], [0, 4], 'VerticalAxis', 'y', ...
'VerticalAxisDir', 'down');
% Visualize the point cloud
view(player3D, ptCloud);

Accepted Answer

Birju Patel
Birju Patel on 27 Apr 2022
Hi,
You will need to calibrate the stereo camera used to capture your images. In the code you posted, you're using calibration parameters from a specific stereo camera setup:
load('handshakeStereoParams.mat');
This won't match your setup and will return in meaningless disparity values.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!