MCPcopy Create free account
hub / github.com/AutonomousFieldRoboticsLab/SVIn / DrawCornersMatches

Method DrawCornersMatches

pose_graph/src/utils/UtilsOpenCV.cpp:121–151  ·  view source on GitHub ↗

-------------------------------------------------------------------------- */ Draw corner matches and return results as a new mat.

Source from the content-addressed store, hash-verified

119/* -------------------------------------------------------------------------- */
120// Draw corner matches and return results as a new mat.
121cv::Mat UtilsOpenCV::DrawCornersMatches(const cv::Mat& img1,
122 const KeypointsCV& corners_1,
123 const cv::Mat& img2,
124 const KeypointsCV& corners_2,
125 const DMatchVec& matches,
126 const bool& random_color) {
127 cv::Mat canvas = UtilsOpenCV::concatenateTwoImages(img1, img2);
128 KeypointCV pt_offset(img1.cols, 0);
129 cv::RNG rng(12345);
130 for (const cv::DMatch& match : matches) {
131 cv::Scalar color;
132 if (random_color) {
133 // Random color is useful to disambiguate between matches
134 color = cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
135 } else {
136 // Green color
137 color = cv::Scalar(0, 255, 0);
138 }
139
140 // TODO TONI REUSE THE OTHER FUNCTIONS!!!!
141 const KeypointCV& corner_1 = corners_1[match.queryIdx];
142 const KeypointCV& corner_2 = corners_2[match.trainIdx];
143
144 // Trace a line from the image on the left to the one image on the right
145 cv::line(canvas, corner_1, corner_2 + pt_offset, color);
146 cv::circle(canvas, corners_1[match.queryIdx], 3, color, 2);
147 cv::circle(canvas, corners_2[match.trainIdx] + pt_offset, 3, color, 2);
148 }
149
150 return canvas;
151}
152
153/* -------------------------------------------------------------------------- */
154cv::Mat UtilsOpenCV::DrawCircles(const cv::Mat img,

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected