| 8 | #include "Types.hpp" |
| 9 | |
| 10 | std::vector<std::tuple<int, int>> GetBoundingBoxPoints(std::vector<od::DetectedObject>& decodedResults, |
| 11 | cv::Mat imageMat) |
| 12 | { |
| 13 | std::vector<std::tuple<int, int>> bboxes; |
| 14 | for(const od::DetectedObject& object : decodedResults) |
| 15 | { |
| 16 | const od::BoundingBox& bbox = object.GetBoundingBox(); |
| 17 | |
| 18 | if (bbox.GetX() + bbox.GetWidth() > imageMat.cols) |
| 19 | { |
| 20 | for (int y = bbox.GetY(); y < bbox.GetY() + bbox.GetHeight(); ++y) |
| 21 | { |
| 22 | bboxes.emplace_back(std::tuple<int, int>{bbox.GetX(), y}); |
| 23 | } |
| 24 | |
| 25 | for (int x = bbox.GetX(); x < imageMat.cols; ++x) |
| 26 | { |
| 27 | bboxes.emplace_back(std::tuple<int, int>{x, bbox.GetY() + bbox.GetHeight() - 1}); |
| 28 | } |
| 29 | |
| 30 | for (int y = bbox.GetY(); y < bbox.GetY() + bbox.GetHeight(); ++y) |
| 31 | { |
| 32 | bboxes.emplace_back(std::tuple<int, int>{imageMat.cols - 1, y}); |
| 33 | } |
| 34 | } |
| 35 | else if (bbox.GetY() + bbox.GetHeight() > imageMat.rows) |
| 36 | { |
| 37 | for (int y = bbox.GetY(); y < imageMat.rows; ++y) |
| 38 | { |
| 39 | bboxes.emplace_back(std::tuple<int, int>{bbox.GetX(), y}); |
| 40 | } |
| 41 | |
| 42 | for (int x = bbox.GetX(); x < bbox.GetX() + bbox.GetWidth(); ++x) |
| 43 | { |
| 44 | bboxes.emplace_back(std::tuple<int, int>{x, imageMat.rows - 1}); |
| 45 | } |
| 46 | |
| 47 | for (int y = bbox.GetY(); y < imageMat.rows; ++y) |
| 48 | { |
| 49 | bboxes.emplace_back(std::tuple<int, int>{bbox.GetX() + bbox.GetWidth() - 1, y}); |
| 50 | } |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | for (int y = bbox.GetY(); y < bbox.GetY() + bbox.GetHeight(); ++y) |
| 55 | { |
| 56 | bboxes.emplace_back(std::tuple<int, int>{bbox.GetX(), y}); |
| 57 | } |
| 58 | |
| 59 | for (int x = bbox.GetX(); x < bbox.GetX() + bbox.GetWidth(); ++x) |
| 60 | { |
| 61 | bboxes.emplace_back(std::tuple<int, int>{x, bbox.GetY() + bbox.GetHeight() - 1}); |
| 62 | } |
| 63 | |
| 64 | for (int y = bbox.GetY(); y < bbox.GetY() + bbox.GetHeight(); ++y) |
| 65 | { |
| 66 | bboxes.emplace_back(std::tuple<int, int>{bbox.GetX() + bbox.GetWidth() - 1, y}); |
| 67 | } |
no test coverage detected