8.结构光:双目视觉(基于视差)

    xiaoxiao2021-04-14  93

    Matlab基于视差进行三维重建的代码如下:

    %% % 清理空间 clc; clear; close all; %% % 导入立体标定参数 load stereoParams.mat % 立体参数的可视化 figure; showExtrinsics(stereoParams); %% % 导入数据 frameLeft = imread('pattern_cam1_im1.png'); frameRight = imread('pattern_cam2_im1.png'); [frameLeftRect, frameRightRect] = ... rectifyStereoImages(frameLeft, frameRight, stereoParams); figure; imshow(stereoAnaglyph(frameLeftRect, frameRightRect)); title('Rectified Frames'); %% % 视差计算 frameLeftGray = rgb2gray(frameLeftRect); frameRightGray = rgb2gray(frameRightRect); disparityMap = disparity(frameLeftGray, frameRightGray); figure; imshow(disparityMap, [0, 64]); title('Disparity Map'); colormap jet colorbar %% % 三维重建 points3D = reconstructScene(disparityMap, stereoParams); % Convert to meters and create a pointCloud object points3D = points3D ./ 1000; ptCloud = pointCloud(points3D, 'Color', frameLeftRect); % Create a streaming point cloud viewer player3D = pcplayer([-3, 3], [-3, 3], [0, 8], 'VerticalAxis', 'y', ... 'VerticalAxisDir', 'down'); % Visualize the point cloud view(player3D, ptCloud);

    转载请注明原文地址: https://ju.6miu.com/read-670005.html

    最新回复(0)