【Matlab Computer Vision System ToolBox】学习笔记-2-3D立体图创建 | 视差图 | 3D点云图
来源:互联网 发布:剑灵萝莉捏脸数据 编辑:程序博客网 时间:2024/04/29 13:06
本系列博客将介绍Matlab中机器视觉工具箱的应用,部分案例,主要关于点云处理方面,更多内容见Matlab官方文档。如有翻译错误请批评指正!所有代码经自己运行测试通过。
【Matlab Computer Vision System ToolBox】学习笔记-1-点云配准流程 | 特征匹配
【Matlab Computer Vision System ToolBox】学习笔记-2-3D立体图创建 | 视差图 | 3D点云图
【Matlab Computer Vision System ToolBox】学习笔记-3 -点云配准 | 噪音去除 | 降采样
【Matlab Computer Vision System ToolBox】学习笔记-4 -点云文件PLY格式
英文原版下载地址
1. Create 3-D Stereo Display -创建3D立体图
>> load('webcamsSceneReconstruction.mat'); //导入双目标定的结果文件>> I1=imread('sceneReconstructionLeft.jpg'); //导入左右图像>> I2=imread('sceneReconstructionRight.jpg');>> [J1,J2]=rectifyStereoImages(I1,I2,stereoParams); //立体矫正>> A=stereoAnaglyph(J1,J2); //创建立体图>> figure;>> imshow(A);
2. Reconstruct 3-D Scene from Disparity Map -从视差图中重建3D场景
>> load('webcamsSceneReconstruction.mat');>> I1=imread('sceneReconstructionLeft.jpg');>> I2=imread('sceneReconstructionRight.jpg');>> [J1,J2]=rectifyStereoImages(I1,I2,stereoParams);>> figure;>> imshow(cat(3,J1(:,:,1),J2(:,:,2:3)),'InitialMagnification',50); //合并矩阵并显示,效果同上stereoAnaglyph
>> disparityMap=disparity(rgb2gray(J1),rgb2gray(J2)); //计算视差>> figure>> imshow(disparityMap,[0,64],'InitialMagnification',50); //adjust the display range [0,64]
当把上述的 [0,64] 改成 [0,255] 后显示效果如下:
从视差图中计算像素在世界坐标系中的位置,并把距离摄像机3.2米到3.7米的区域分割出来。
>> xyzPoints=reconstructScene(disparityMap,stereoParams);>> Z=xyzPoints(:,:,3);>> mask=repmat(Z>3200 & Z<3700,[1,1,3]); >> J1(~mask)=0;>> imshow(J1,'InitialMagnification',50);
3. Read Point Cloud from a PLY File -读入点云数据
>> ptCloud=pcread('teapot.ply');>> pcshow(ptCloud);
点云是以 ply 结尾的数据格式存储,具体点云数据 ply 见后文。可对点云可视化图进行放大缩小旋转等操作。
同时可将3D点云数据写入 PLY 文件。如果显示没有写入权限,则关闭Matlab,用管理员权限打开。
pcwrite(ptCloud,'teapotOut','PLYFormat','binary');4. Visualize the Difference Between Two Point Clouds -可视化观察两个点云的区别
>> load('livingRoom'); //88个点云数组集>> pc1=livingRoomData{1};>> pc2=livingRoomData{2}; // 取前2组点云>> figure;>> pcshowpair(pc1,pc2,'VerticalAxis','Y','VerticalAxisDir','Down'); //显示点云>> title('Difference Between Tow Point Clouds')>> xlabel('X(m)');>> ylabel('Y(m)');>> zlabel('Z(m)');
5. View Rotating 3-D Point Cloud
>> pcCloud=pcread('teapot.ply');>> x=pi/180;>> R=[cos(x) sin(x) 0 0;-sin(x) cos(x) 0 0;0 0 1 0;0 0 0 1];>> tform=affine3d(R); //定义旋转矩阵和3D平移>> lower=min([pcCloud.XLimits pcCloud.YLimits]);>> upper=max([pcCloud.XLimits pcCloud.YLimits]);>> xlimits=[lower upper];>> ylimits=[lower upper];>> zlimits=pcCloud.ZLimits; //找出xy的最小最大值,防止不被显示>> player=pcplayer(xlimits,ylimits,zlimits);>> xlabel(player.Axes,'X(m)');>> ylabel(player.Axes,'Y(m)');>> zlabel(player.Axes,'Z(m)');>> for i=1:360 //以Z轴旋转ptCloud=pctransform(pcCloud,tform);view(player,pcCloud);end
0 0
- 【Matlab Computer Vision System ToolBox】学习笔记-2-3D立体图创建 | 视差图 | 3D点云图
- 【Matlab Computer Vision System ToolBox】学习笔记-3 -点云配准 | 噪音去除 | 降采样
- 【Matlab Computer Vision System ToolBox】学习笔记-4 -点云文件PLY格式
- 3D点云图
- 【Matlab Computer Vision System ToolBox】学习笔记-1-点云配准流程 | 特征匹配
- matlab-Computer Vision System ToolBox的系统对象使用
- openGL显示3d 点云图像
- Matlab Computer Vision System 例程笔记
- Piotr's Computer Vision Matlab Toolbox 安装
- Piotr's Computer Vision Matlab Toolbox 安装
- 3D\X20视差效果
- 3D散点 表面,2D散点,边界。 matlab 儿子的papa
- Computer Graphics Using Java 2D and 3D
- Computer Graphics Using Java 2D and 3D
- DIV跷跷板特效,3D视差效果
- 【Unity 3D游戏开发学习笔记】 UI System
- 在matlab中安装Piotr's Computer Vision Matlab Toolbox工具箱
- Direct 3D学习笔记二:顶点的创建
- what is your grade
- 使用XMLHttpRequest异步通信
- Objective-C 协议(protorcol)
- C++:动态内存分配和释放、类型转换、面向对象编程、构造函数
- 23. Merge k Sorted Lists
- 【Matlab Computer Vision System ToolBox】学习笔记-2-3D立体图创建 | 视差图 | 3D点云图
- hdu 1512 左偏树
- 2015年第六届蓝桥杯省赛真题之二星系炸弹
- 使用jsp从后台获取数据后在前端为checkbox打勾选中的方法
- Java反射之getInterfaces()方法
- CodeForces - 742B
- 浅谈web网站架构演变过程
- 支付宝商户收款二维码在哪里?怎么开通商户收款吗
- YalMip