39 #include <opencv2/stitching/detail/util.hpp> 48 const std::vector<cv::Mat>& grids,
const std::vector<cv::Rect>& rois)
52 nav_msgs::OccupancyGrid::Ptr result_grid(
new nav_msgs::OccupancyGrid());
54 std::vector<cv::Point> corners;
55 corners.reserve(grids.size());
56 std::vector<cv::Size> sizes;
57 sizes.reserve(grids.size());
58 for (
auto& roi : rois) {
59 corners.push_back(roi.tl());
60 sizes.push_back(roi.size());
62 cv::Rect dst_roi = cv::detail::resultRoi(corners, sizes);
64 result_grid->info.width =
static_cast<uint
>(dst_roi.width);
65 result_grid->info.height =
static_cast<uint
>(dst_roi.height);
66 result_grid->data.resize(static_cast<size_t>(dst_roi.area()), -1);
68 cv::Mat result(dst_roi.size(), CV_8S, result_grid->data.data());
70 for (
size_t i = 0; i < grids.size(); ++i) {
72 cv::Rect roi = cv::Rect(corners[i] - dst_roi.tl(), sizes[i]);
73 cv::Mat result_roi(result, roi);
76 cv::Mat warped_signed (grids[i].size(), CV_8S, const_cast<uchar*>(grids[i].ptr()));
78 cv::max(result_roi, warped_signed, result_roi);
nav_msgs::OccupancyGrid::Ptr compose(const std::vector< cv::Mat > &grids, const std::vector< cv::Rect > &rois)