Opencv.js DrawMatchesFlags workaround

this is an FYI so others don’t get tripped up by the same issue:

If you are using opencv.js (javascript) and are trying to use this API with FLAGS:

void cv::drawKeypoints ( InputArray image ,
const std::vector< KeyPoint > & keypoints ,
InputOutputArray outImage ,
const Scalar & color = Scalar::all(-1) ,
DrawMatchesFlags flags = DrawMatchesFlags::DEFAULT
)

This will fail:

cv.drawKeypoints(im2Gray, keypoints2, keypoints2_img, keypointcolor, cv.DRAW_RICH_KEYPOINTS); 

You need to use these flags instead:

cv.DrawMatchesFlags_DEFAULT: 0
cv.DrawMatchesFlags_DRAW_OVER_OUTIMG: 1
cv.DrawMatchesFlags_DRAW_RICH_KEYPOINTS: 4
cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS: 2

more here

2 Likes