资源简介
用MATLAB实现从视差图重建3D点云并显示出来,得到的rgb+XYZ
代码片段和文件信息
% clc
clear
close all;
tic
I00= imread(‘im0.png‘);
I10= imread(‘im1.png‘);
D0= imread(‘Sword1_perfect_d.png‘);
% B = imresize(Ammethod);%A放大m倍method:‘nearest‘(默认值)最近邻插值‘bilinear‘双线性插值‘bicubic‘双三次插值
I0=imresize(I001/4‘bilinear‘);
[mn]=size(D0);
x=1:m;
y=1:n;
u=repmat(ym1);
v=repmat(x‘1n);
cam0=[6872.874 0 1329.49; 0 6872.874 954.485; 0 0 1];
cam1=[6872.874 0 1623.46; 0 6872.874 954.485; 0 0 1];
doffs=293.97/4;
Tx=174.724;
fx=cam0(11)/4;
fy=cam0(22)/4;
Ox=cam0(13)/4;
Oy=cam0(23)/4;
D=double(D0);
Z=fx*Tx./(D+doffs);
% Z=f*Tx./(D+doffs)/255*1001;
% X=(u-Ox).*Tx./(D+doffs);
% Y=(v-Oy).*Tx./(D+doffs);
X=(u-Ox).*Z/fx;
Y=(v-Oy).*Z/fy;
Recon_3D(::3)=Z;
Recon_3D(::1)=X;
Recon_3D(::2)=Y;
figure;
pcshow(Recon_3D);
title(‘测试图‘);xlabel(‘X‘);ylabel(‘Y‘);zlabel(‘Z‘);
%贴纹理显示
% J = flipud(imresize(I0size(Z)));
figure;
pcshow(Recon_3DI0);
title(‘测试图‘);xlabel(‘X‘);ylabel(‘Y‘);zlabel(‘Z‘);
toc
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 219 2016-09-26 09:27 3D_reconstruction\1.txt
文件 213 2016-09-19 15:24 3D_reconstruction\calib.txt
文件 38451 2016-09-21 10:09 3D_reconstruction\depth.jpg
文件 6949962 2016-09-26 09:32 3D_reconstruction\im0.png
文件 5262955 2016-09-26 10:04 3D_reconstruction\im02.png
文件 7435246 2016-09-26 09:32 3D_reconstruction\im1.png
文件 5280860 2016-09-26 10:04 3D_reconstruction\im12.png
文件 985 2016-09-26 10:31 3D_reconstruction\Sword1_p.m
文件 28561 2016-09-26 09:13 3D_reconstruction\Sword1_perfect_d.png
文件 28302 2016-09-26 09:13 3D_reconstruction\Sword2_perfect_d.png
目录 0 2016-11-14 21:26 3D_reconstruction
----------- --------- ---------- ----- ----
25025754 11
评论
共有 条评论