I'm trying to get the information of matching points and their matches, just like the sample image in the paper.
I have tried using pairwise_matches but the matching seemed incorrectly:
Mat img1 = images_data[m1].img;
Mat img2 = images_data[m2].img;
Mat result = Mat::zeros(max(img1.rows, img2.rows),
img1.cols + img2.cols,
CV_8UC3);
// 分割矩阵
Mat left (result, Rect(0, 0, img1.cols, img1.rows));
Mat right(result, Rect(img1.cols, 0, img2.cols, img2.rows));
// 复制矩阵
img1.copyTo(left);
img2.copyTo(right);
for (int i = 0; i < pairwise_matches[pm_index].matches.size(); i ++) {
int src = pairwise_matches[pm_index].matches[i].queryIdx;
int dest = pairwise_matches[pm_index].matches[i].trainIdx;
Point2 src_p = images_data[m1].mesh_2d->getVertices()[src];
Point2 dest_p = images_data[m2].mesh_2d->getVertices()[dest];
Scalar color(rand() % 256, rand() % 256, rand() % 256);
circle(result, src_p, 3, color, -1);
line(result, src_p, dest_p + Point2(img1.cols, 0), color, 1, LINE_AA);
circle(result, dest_p + Point2(img1.cols, 0), 3, color, -1);
}
imwrite(parameter.debug_dir + "matching_points" + to_string(i) + ".png", result);
Could you tell me the right way to do this? Besides, how to display only the good matches(how to judge the quality of a match)?
I'm trying to get the information of matching points and their matches, just like the sample image in the paper. I have tried using
pairwise_matches
but the matching seemed incorrectly:Could you tell me the right way to do this? Besides, how to display only the good matches(how to judge the quality of a match)?