-2

I want to remove lines and keypoints. Is there a function other than drawMatches or can I make lines and keypoints invisible in drawMatches?

Mat img_matches;
drawMatches( img_object, keypoints_object, img_scene, keypoints_scene,
           good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
           std::vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );

A picture

Miki
  • 40,887
  • 13
  • 123
  • 202
MJ Kwon
  • 65
  • 8
  • 3
    so why do you call `drawMatches` if you don't want to _draw matches_? – Miki Mar 13 '19 at 12:47
  • @Miki For img_matches. I draw green lines using line function. line( img_matches, scene_corners[0] + Point2f( img_object.cols, 0), scene_corners[1] + Point2f( img_object.cols, 0), Scalar(0, 255, 0), 4 ); – MJ Kwon Mar 13 '19 at 12:52

1 Answers1

3

You can mask out all matches with the matchesMask parameter:

Mat img_matches;
std::vector<char> mask_matches(good_matches.size(), 0);
drawMatches( 
    img_object, 
    keypoints_object, 
    img_scene, 
    keypoints_scene,
    good_matches, 
    img_matches, 
    Scalar::all(-1), 
    Scalar::all(-1),
    mask_matches, // <----
    DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS 
);

Since you basically just need the two images side-by-side, you can just create the image by yourself. You can find an example here.

Miki
  • 40,887
  • 13
  • 123
  • 202