Create2DMap: eroding only on cells having at least 3 empty neighbor cells

This commit is contained in:
matlabbe
2015-09-16 17:12:01 -04:00
parent b8043665fe
commit 007c192b6a
2 changed files with 8 additions and 7 deletions
+2 -1
View File
@@ -1334,6 +1334,7 @@ bool Rtabmap::process(
// When analysing logs, it's convenient to know // When analysing logs, it's convenient to know
// if the hypothesis would be rejected if T_loop would be lower. // if the hypothesis would be rejected if T_loop would be lower.
rejectedHypothesis = true; rejectedHypothesis = true;
UWARN("rejected hypothesis: under loop ratio %f < %f", _highestHypothesis.second, _loopRatio*lastHighestHypothesis.second);
} }
//for statistic... //for statistic...
@@ -1791,7 +1792,7 @@ bool Rtabmap::process(
rejectedHypothesis = transform.isNull(); rejectedHypothesis = transform.isNull();
if(rejectedHypothesis) if(rejectedHypothesis)
{ {
UINFO("Rejected loop closure %d -> %d: %s", UWARN("Rejected loop closure %d -> %d: %s",
_loopClosureHypothesis.first, signature->id(), rejectedMsg.c_str()); _loopClosureHypothesis.first, signature->id(), rejectedMsg.c_str());
} }
} }
+6 -6
View File
@@ -349,7 +349,7 @@ cv::Mat create2DMapFromOccupancyLocalMaps(
if(erode) if(erode)
{ {
// remove obstacles which touch to empty cells but not unknown cells // remove obstacles which touch at least 3 empty cells but not unknown cells
cv::Mat erodedMap = map.clone(); cv::Mat erodedMap = map.clone();
for(std::list<std::pair<int,int> >::iterator iter = obstacleIndices.begin(); for(std::list<std::pair<int,int> >::iterator iter = obstacleIndices.begin();
iter!= obstacleIndices.end(); iter!= obstacleIndices.end();
@@ -357,11 +357,11 @@ cv::Mat create2DMapFromOccupancyLocalMaps(
{ {
int i = iter->first; int i = iter->first;
int j = iter->second; int j = iter->second;
bool touchEmpty = map.at<char>(i+1, j) == 0 || int touchEmpty = (map.at<char>(i+1, j) == 0?1:0) +
map.at<char>(i-1, j) == 0 || (map.at<char>(i-1, j) == 0?1:0) +
map.at<char>(i, j+1) == 0 || (map.at<char>(i, j+1) == 0?1:0) +
map.at<char>(i, j-1) == 0; (map.at<char>(i, j-1) == 0?1:0);
if(touchEmpty && map.at<char>(i+1, j) != -1 && if(touchEmpty>=3 && map.at<char>(i+1, j) != -1 &&
map.at<char>(i-1, j) != -1 && map.at<char>(i-1, j) != -1 &&
map.at<char>(i, j+1) != -1 && map.at<char>(i, j+1) != -1 &&
map.at<char>(i, j-1) != -1) map.at<char>(i, j-1) != -1)