MATLAB应用3——深度视觉 奥比中光Astra S显示RGB和深度信息

首先从官网下载OpenNI驱动并安装,以及添加环境变量。

MATLAB代码:

% 参考:https://blog.csdn.net/limingmin2020/article/details/109445787

%% 首次使用需编译mxNI.cpp文件,生成mxNI.mexw64

mex mxNI.cpp -IF:\VS2017\VC\Astra_S\OpenNI\Win64-Release\sdk\Include ...

-LF:\VS2017\VC\Astra_S\OpenNI\Win64-Release\sdk\libs ...

-lOpenNI2.lib

之后就可以愉快的玩耍了。

%%

mxNI(0); %初始化

%% RGB

mxNI(14, 12); % 15:1280*1024. 12: 640*480

for i=1:1000

imaRGB = mxNI(3); %RGB

imshow(imaRGB);

end

%% Depth

mxNI(13, 4); % 2: 320*240. 4: 640*480

for i=1:1000

imaDepth1 = mxNI(2); %Depth

% imshow(imaDepth,[]); %黑白图

% colormap jet;

% % colorbar

% pause(0.001);

% imaDepth2 = ind2rgb(im2uint8(mat2gray(imaDepth1)),jet(65535));

imaDepth2 = ind2rgb(im2uint8(mat2gray(imaDepth1)),hsv(256));

imshow(imaDepth2);

end

%% RGB&Depth

for i=1:1000

imaRGB = mxNI(3); %RGB

imaRGB=im2double(imaRGB);

% figure(1);

% imshow(imaRGB);

imaDepth1 = mxNI(2); %Depth

imaDepth2 = ind2rgb(im2uint8(mat2gray(imaDepth1)),hsv(256));

% figure(2);

% imshow(imaDepth2);

ima(:,:,1)=[imaRGB(:,:,1),imaDepth2(:,:,1)];

ima(:,:,2)=[imaRGB(:,:,2),imaDepth2(:,:,2)];

ima(:,:,3)=[imaRGB(:,:,3),imaDepth2(:,:,3)];

imshow(ima);

end

%% 关闭设备。注意不要长时间看红外投影仪,对眼镜有损伤。

mxNI(1);% Closes the device - nothing returned

资料打包:https://download.csdn.net/download/fengyuzhe13/87408247

资料包含的文件:

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fengyuzhe13

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值