This is a ROS package for map processing. It is used to process the map image file or ROS map topic.
The package currently includes:
- [space volume calculator] (src/calculate_space.cpp): calculate the space volume by extract the acceptable area in the map
The pipelines of each part above will be introduced in the following.
- Aim
To calculate the area and volume by segmenting the map generated by SLAM.
- Pipelines
-
Input map
-
Median blur
Use
cv::medianBlur
to smooth the image, remove small holes and measurement errors. -
Threshold
Use
cv::inRange
to keep freespace and obstacles. -
Morphology operation: open
Use
cv::morphologyEx
withcv::MORPH_OPEN
to ignore seperated freespace. -
Morphology operation: close
Use
cv::morphologyEx
withcv::MORPH_CLOSE
to fill holes. -
Find contour
Use
cv::findContours
withcv::RETR_TREE
to find all contours. Then traverse all the contours to find the largest one bycv::contourArea
. -
Decide possible freespace
Use
cv::approxPolyDP
to fit the largest contour. Then generate the space bycv::fillPoly
. -
Exclude non-accessible area
Use
cv::drawContours
to fill those contours larger than theINNER_AREA_THRESH
. -
Calculate area and volume
Traverse the freespace image to count the green pixels. Then calculate the space area and volume with the given
RESOLUTION
of the map and the argumentfloor_height
. -
Show merged results
Use
cv::addWeighted
to add freespace image to the map.
-