mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Depth16 set invalid for values = 65535
This commit is contained in:
@@ -502,7 +502,20 @@ std::vector<cv::KeyPoint> Feature2D::generateKeypoints(const cv::Mat & image, co
|
||||
mask = cv::Mat::zeros(maskIn.rows, maskIn.cols, CV_8UC1);
|
||||
for(int i=0; i<(int)mask.total(); ++i)
|
||||
{
|
||||
float value = maskIn.type()==CV_16UC1?float(((unsigned short*)maskIn.data)[i])/1000.0f:((float*)maskIn.data)[i];
|
||||
float value = 0.0f;
|
||||
if(maskIn.type()==CV_16UC1)
|
||||
{
|
||||
if(((unsigned short*)maskIn.data)[i] > 0 &&
|
||||
((unsigned short*)maskIn.data)[i] < std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
value = float(((unsigned short*)maskIn.data)[i])*0.0001f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ((float*)maskIn.data)[i];
|
||||
}
|
||||
|
||||
if(value>_minDepth &&
|
||||
(_maxDepth == 0.0f || value <= _maxDepth))
|
||||
{
|
||||
|
||||
@@ -994,7 +994,19 @@ float getDepth(
|
||||
int u_end = std::min(u+1, depthImage.cols-1);
|
||||
int v_end = std::min(v+1, depthImage.rows-1);
|
||||
|
||||
float depth = isInMM?(float)depthImage.at<unsigned short>(v,u)*0.001f:depthImage.at<float>(v,u);
|
||||
float depth = 0.0f;
|
||||
if(isInMM)
|
||||
{
|
||||
if(depthImage.at<unsigned short>(v,u) > 0 &&
|
||||
depthImage.at<unsigned short>(v,u) < std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
depth = float(depthImage.at<unsigned short>(v,u))*0.001f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
depth = depthImage.at<float>(v,u);
|
||||
}
|
||||
|
||||
if((depth==0.0f || !uIsFinite(depth)) && estWithNeighborsIfNull)
|
||||
{
|
||||
@@ -1007,7 +1019,19 @@ float getDepth(
|
||||
{
|
||||
if((uu == u && vv!=v) || (uu != u && vv==v))
|
||||
{
|
||||
float d = isInMM?(float)depthImage.at<unsigned short>(vv,uu)*0.001f:depthImage.at<float>(vv,uu);
|
||||
float d = 0.0f;
|
||||
if(isInMM)
|
||||
{
|
||||
if(depthImage.at<unsigned short>(vv,uu) > 0 &&
|
||||
depthImage.at<unsigned short>(vv,uu) < std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
depth = float(depthImage.at<unsigned short>(vv,uu))*0.001f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d = depthImage.at<float>(vv,uu);
|
||||
}
|
||||
if(d!=0.0f && uIsFinite(d))
|
||||
{
|
||||
if(tmp == 0.0f)
|
||||
@@ -1042,7 +1066,20 @@ float getDepth(
|
||||
{
|
||||
if(!(uu == u && vv == v))
|
||||
{
|
||||
float d = isInMM?(float)depthImage.at<unsigned short>(vv,uu)*0.001f:depthImage.at<float>(vv,uu);
|
||||
float d = 0.0f;
|
||||
if(isInMM)
|
||||
{
|
||||
if(depthImage.at<unsigned short>(vv,uu) > 0 &&
|
||||
depthImage.at<unsigned short>(vv,uu) < std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
depth = float(depthImage.at<unsigned short>(vv,uu))*0.001f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d = depthImage.at<float>(vv,uu);
|
||||
}
|
||||
|
||||
// ignore if not valid or depth difference is too high
|
||||
if(d != 0.0f && uIsFinite(d) && fabs(d - depth) < maxZError)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user