Ask Your Question
0

findFundamentalMat and drawMatches with mask

asked 2017-10-19 07:30:55 -0600

Grillteller gravatar image

I want to draw the inlier matches of my Fundamental Matrix to interpretate the results. I am using opencv 3.2 and C++. The parameter mask in findFundamentalMat is used if one uses a method like RANSAC to dermine the inliers and is of typevector<uchar> .

In the documentation it says that in drawMatches the parameter "matchesMask - Mask determining which matches are drawn. If the mask is empty, all matches are drawn." But here only a vector<char> is accepted. Do I have to convert my vector from uchar to char and how do I do that?

Here is my code:

   vector<uchar> inliers(matched_points_1.size());
   Mat F = findFundamentalMat(matched_points_1, matched_points_2, CV_FM_RANSAC, 3, 0.99, inliers);

   Mat matched_points;

   drawMatches(img_1, keypoints_1, img_2, keypoints_2, sym_matches, matched_points, Scalar::all(-1), Scalar::all(-1), inliers, 0);
   imshow("Matched points", matched_points);

If I try it like that it says: "Wrong argumenttypes."

If I change my inliers vector to vector<char> I get the error

OpenCV Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0)) in cv::_OutputArray::create, file C:\opencv\opencv-master\modules\core\src\matrix.cpp, line 2461

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-10-20 04:30:52 -0600

Grillteller gravatar image

I found it myself: Just change the vector<uchar> to vector<char> with:

vector<char> inliers_c(inliers.begin(), inliers.end());
drawMatches(img_1, keypoints_1, img_2, keypoints_2, sym_matches, matched_points_RANSAC, Scalar::all(-1), Scalar::all(-1), inliers_c, 0);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-10-19 07:30:55 -0600

Seen: 3,572 times

Last updated: Oct 19 '17