| 19 | GridMapCvProcessing::~GridMapCvProcessing() {} |
| 20 | |
| 21 | bool GridMapCvProcessing::changeResolution(const GridMap& gridMapSource, GridMap& gridMapResult, const double resolution, |
| 22 | const int interpolationAlgorithm) { |
| 23 | GridMap gridMapSourceCopy(gridMapSource); |
| 24 | gridMapSourceCopy.convertToDefaultStartIndex(); |
| 25 | const double sizeFactor = gridMapSourceCopy.getResolution() / resolution; |
| 26 | bool firstLayer = true; |
| 27 | for (const auto& layer : gridMapSourceCopy.getLayers()) { |
| 28 | cv::Mat imageSource, imageResult; |
| 29 | const float minValue = gridMapSourceCopy.get(layer).minCoeffOfFinites(); |
| 30 | const float maxValue = gridMapSourceCopy.get(layer).maxCoeffOfFinites(); |
| 31 | const bool hasNaN = gridMapSourceCopy.get(layer).hasNaN(); |
| 32 | bool result; |
| 33 | if (hasNaN) { |
| 34 | result = GridMapCvConverter::toImage<unsigned short, 4>(gridMapSourceCopy, layer, CV_16UC4, minValue, maxValue, imageSource); |
| 35 | } else { |
| 36 | result = GridMapCvConverter::toImage<unsigned short, 1>(gridMapSourceCopy, layer, CV_16UC1, minValue, maxValue, imageSource); |
| 37 | } |
| 38 | if (!result) return false; |
| 39 | cv::resize(imageSource, imageResult, cv::Size(0.0, 0.0), sizeFactor, sizeFactor, interpolationAlgorithm); |
| 40 | if (firstLayer) { |
| 41 | if (!GridMapCvConverter::initializeFromImage(imageResult, resolution, gridMapResult, gridMapSourceCopy.getPosition())) return false; |
| 42 | firstLayer = false; |
| 43 | } |
| 44 | if (hasNaN) { |
| 45 | result = GridMapCvConverter::addLayerFromImage<unsigned short, 4>(imageResult, layer, gridMapResult, minValue, maxValue); |
| 46 | } else { |
| 47 | result = GridMapCvConverter::addLayerFromImage<unsigned short, 1>(imageResult, layer, gridMapResult, minValue, maxValue); |
| 48 | } |
| 49 | if (!result) return false; |
| 50 | } |
| 51 | gridMapResult.setFrameId(gridMapSourceCopy.getFrameId()); |
| 52 | gridMapResult.setTimestamp(gridMapSourceCopy.getTimestamp()); |
| 53 | gridMapResult.setBasicLayers(gridMapSourceCopy.getBasicLayers()); |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | GridMap GridMapCvProcessing::getTransformedMap(GridMap&& gridMapSource, const Eigen::Isometry3d& transform, |
| 58 | const std::string& heightLayerName, const std::string& newFrameId) { |
nothing calls this directly
no test coverage detected