Skip to content

Improving Performance of GridMapCvConverter::toImage and addLayerFromImage on large grids #359

@rooshm

Description

@rooshm

on a 501x501 gridmap, the toImage function takes about 200ms on an i7-8700 CPU. Same is true for the addLayerFromImage for the same. I need to perform a behaviour similar to the one illustrated in the opencv_demo, using OpenCV's functions to perform manipulations on a layer and save as another layer. Setting the geometry of the map in the opencv_demo_node as map.setGeometry(Length(5, 5), 0.01); replicates the performance.

On a look at the source code, the iterators can be parallelised with TBB (as used in in grid_map_filters), which upped my performance to 40 ms or so, but even more advantage is gained by the use of <opencv2/core/eigen.hpp> eigen2cv and cv2eigen functions, with performance in the order of 5 ms or so. This leverages that grid_map::Matrix is a typedef of eigen:Matrix. I'd be happy to submit a pull request either way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions