Table Of Contents

Previous topic

Matching with binary descriptors

Next topic

Line Features Tutorial

Drawing Functions for Keylines and Matches


Draws the found matches of keylines from two images.

C++: void drawLineMatches(const Mat& img1, const std::vector<KeyLine>& keylines1, const Mat& img2, const std::vector<KeyLine>& keylines2, const std::vector<DMatch>& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singleLineColor=Scalar::all(-1), const std::vector<char>& matchesMask=std::vector<char>(), int flags=DrawLinesMatchesFlags::DEFAULT )
  • img1 – first image
  • keylines1 – keylines extracted from first image
  • img2 – second image
  • keylines2 – keylines extracted from second image
  • matches1to2 – vector of matches
  • outImg – output matrix to draw on
  • matchColor – drawing color for matches (chosen randomly in case of default value)
  • singleLineColor – drawing color for keylines (chosen randomly in case of default value)
  • matchesMask – mask to indicate which matches must be drawn
  • flags – drawing flags


If both matchColor and singleLineColor are set to their default values, function draws matched lines and line connecting them with same color

The structure of drawing flags is shown in the following:

/* struct for drawing options */
struct CV_EXPORTS DrawLinesMatchesFlags
            DEFAULT = 0, // Output image matrix will be created (Mat::create),
                         // i.e. existing memory of output image may be reused.
                         // Two source images, matches, and single keylines
                         // will be drawn.
            DRAW_OVER_OUTIMG = 1, // Output image matrix will not be
                           // created (using Mat::create). Matches will be drawn
                           // on existing content of output image.
            NOT_DRAW_SINGLE_LINES = 2 // Single keylines will not be drawn.


Draws keylines.

C++: void drawKeylines(const Mat& image, const std::vector<KeyLine>& keylines, Mat& outImage, const Scalar& color=Scalar::all(-1), int flags=DrawLinesMatchesFlags::DEFAULT )
  • image – input image
  • keylines – keylines to be drawn
  • outImage – output image to draw on
  • color – color of lines to be drawn (if set to defaul value, color is chosen randomly)
  • flags – drawing flags