从模型库里拉出来一个Kinect相机放在合适位置:
设置好像素,不是标准像素值vrep有警告(可能数据有误),忽略即可
同样的像素值,在c++ 端:
int w = 640, h =480;
simxInt resolution[2] = {0,0};
simxFloat mem[32]={0};
simxFloat *point = mem;
simxFloat ** depth1 = new simxFloat *[w*h];
int res = simxGetVisionSensorDepthBuffer(m_vrepshow.client_id,m_vrepshow.depthcam_handle,colorresolution,depth1, simx_opmode_blocking);
if(res == simx_return_ok)
{
w = resolution[0];
h = resolution[1];
cv::Mat depth2(Size(w,h),CV_8UC1);
cout << "resolution : x = " << resolution[0] << " . y = " << resolution[1] << endl;
for(int i=0;i<h;++i)
{
for(int j=0;j<w;++j)
{
depth2.at<uchar>(i,j) = (uchar)((*(*depth1+j + i*w))*255);
}
}
cv::Mat depth3;
cv::flip(depth2,depth3, 0);
char filename[64];
sprintf(filename,"../images/vrepdepth%d.jpg",index);
imwrite(filename,depth3);
cout << "save depth image "<< filename <<endl;
保存的图片:深度图变成了单通道灰度图
深度信息已经被vrep归一化了,所以需要自己再远程处理,归一化规则为
depth = (dis-mindistance)/(maxdistance-mindistance)
(dis 默认小于maxdistance,超出该distance的像素点数据就是max)
mindis 和 maxdis 是 vrep 中设置的深度相机有效范围
反推规则:
先得到像素点的数据信息:即深度 depth,
distance = depth*(maxdistance - mindistance)+ mindistance.
max-min 即为超出最小有效距离之外的距离的放缩系数
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)