### Navigation

- index
- next |
- previous |
- OpenCV 2.4.10.0 documentation »
- OpenCV API Reference »
- features2d. 2D Features Framework »

# Drawing Function of Keypoints and Matches

## drawMatches

Draws the found matches of keypoints from two images.

C++:`` void `drawMatches`(const Mat& img1, const vector<KeyPoint>& keypoints1, const Mat& img2, const vector<KeyPoint>& keypoints2, const vector<DMatch>& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const vector<char>& matchesMask=vector<char>(), int flags=DrawMatchesFlags::DEFAULT )

C++:`` void `drawMatches`(const Mat& img1, const vector<KeyPoint>& keypoints1, const Mat& img2, const vector<KeyPoint>& keypoints2, const vector<vector<DMatch>>& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const vector<vector<char>>& matchesMask=vector<vector<char> >(), int flags=DrawMatchesFlags::DEFAULT )

  Parameters: | img1 – First source image. keypoints1 – Keypoints from the first source image. img2 – Second source image. keypoints2 – Keypoints from the second source image. matches1to2 – Matches from the first image to the second one, which means that `keypoints1[i]` has a corresponding point in `keypoints2[matches[i]]` . outImg – Output image. Its content depends on the `flags` value defining what is drawn in the output image. See possible `flags` bit values below. matchColor – Color of matches (lines and connected keypoints). If `matchColor==Scalar::all(-1)` , the color is generated randomly. singlePointColor – Color of single keypoints (circles), which means that keypoints do not have the matches. If `singlePointColor==Scalar::all(-1)` , the color is generated randomly. matchesMask – Mask determining which matches are drawn. If the mask is empty, all matches are drawn. flags – Flags setting drawing features. Possible `flags` bit values are defined by `DrawMatchesFlags`.

This function draws matches of keypoints from two images in the output image. Match is a line connecting two keypoints (circles). The structure `DrawMatchesFlags` is defined as follows:

    struct DrawMatchesFlags
    {
        enum
        {
            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 keypoints
                         // will be drawn.
                         // For each keypoint, only the center point will be
                         // drawn (without a circle around the keypoint with the
                         // keypoint size and orientation).
            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_POINTS = 2, // Single keypoints will not be drawn.
            DRAW_RICH_KEYPOINTS = 4 // For each keypoint, the circle around
                           // keypoint with keypoint size and orientation will
                           // be drawn.
        };
    };

## drawKeypoints

Draws keypoints.

C++:`` void `drawKeypoints`(const Mat& image, const vector<KeyPoint>& keypoints, Mat& outImage, const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT )

  Parameters: | image – Source image. keypoints – Keypoints from the source image. outImage – Output image. Its content depends on the `flags` value defining what is drawn in the output image. See possible `flags` bit values below. color – Color of keypoints. flags – Flags setting drawing features. Possible `flags` bit values are defined by `DrawMatchesFlags`. See details above in `drawMatches()` .

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.10.0 documentation »
- OpenCV API Reference »
- features2d. 2D Features Framework »