Skip to content

Commit

Permalink
added map correction for segmented map
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-rmb committed Jun 7, 2019
1 parent e5ac3cd commit 88a5897
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ipa_room_segmentation/ros/src/room_segmentation_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,23 @@ void RoomSegmentationServer::execute_segmentation_server(const ipa_building_msgs
else if (room_segmentation_algorithm_ == 99)
{
// pass through segmentation: takes a map which is already separated into unconnected areas and returns these as the resulting segmentation in the format of this program
original_img.convertTo(segmented_map, CV_32SC1, 256, 0); // occupied space = 0, free space = 65280
// todo: closing operation explicitly for bad maps --> needs parameterization
//original_img.convertTo(segmented_map, CV_32SC1, 256, 0); // occupied space = 0, free space = 65280
cv::Mat original_img_eroded, temp;
cv::erode(original_img, temp, cv::Mat(), cv::Point(-1, -1), 3);
cv::dilate(temp, original_img_eroded, cv::Mat(), cv::Point(-1, -1), 3);
original_img_eroded.convertTo(segmented_map, CV_32SC1, 256, 0); // occupied space = 0, free space = 65280
int label_index = 1;

// cv::imshow("original_img", original_img_eroded);
// cv::waitKey();

for (int y = 0; y < segmented_map.rows; y++)
{
for (int x = 0; x < segmented_map.cols; x++)
{
// if original map is occupied space here or if the segmented map has already received a label for that cell --> skip
if (original_img.at<uchar>(y,x) != 255 || segmented_map.at<int>(y,x)!=65280)
if (original_img_eroded.at<uchar>(y,x) != 255 || segmented_map.at<int>(y,x)!=65280)
continue;

// fill each room area with a unique id
Expand Down

0 comments on commit 88a5897

Please sign in to comment.