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

MATLAB应用3——深度视觉 奥比中光Astra S显示RGB和深度信息_第1张图片

首先从官网下载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

MATLAB应用3——深度视觉 奥比中光Astra S显示RGB和深度信息_第2张图片

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

%%

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

资料包含的文件:

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

你可能感兴趣的:(Matlab,matlab,开发语言,深度视觉)