Drawing Matches of SuperGlue with OpenCV

301 views Asked by At

I'm trying to use OpenCV's cv.drawMatches() function to draw the keypoint matches of SuperGlue.

drawMatches() has parameters keypoints1, keypoints2 and matches, that are in different form from SuperGlue's.

SuperGlue simply outputs the coordinates of the keypoints, but opencv is creating keypoint objects. And there's a converter of that in OpenCV, pts = cv2.KeyPoint_convert(kp) that works fine.

However, I didn't see any converter for the matches parameter.

SuperGlue outputs something like this:

array([ -1,  -1,  -1,  -1,   8,  -1,  -1,  25,  -1,  24,  -1,  21,  -1,
    28,  29,  -1,  -1,  32,  -1,  -1,  -1,  45,  37,  44,  -1,  -1,
    -1,  -1,  50,  -1,  53,  -1,  48,  60,  -1,  -1,  -1,  59,  64,
    -1,  -1,  -1,  -1,  70,  71,  -1,  -1,  -1,  -1,  -1,  82,  -1,

But opencv outputs a DMatch object, like this:

(<DMatch 0000021FD87A3690>,
 <DMatch 0000021FEF895110>,
 <DMatch 0000021FEF894BF0>,
 <DMatch 0000021FEF894E10>,

I tried to put the matches of the SuperGlue to the cv.drawMatches(), got an error like this:

error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'drawMatches'
> Overload resolution failed:
>  - Can't parse 'matches1to2'. Sequence item with index 0 has a wrong type
>  - Can't parse 'matches1to2'. Sequence item with index 0 has a wrong type

Is there any way to convert the SuperGlue's match type to OpenCV's?

Or, in general, is there a way to draw the SuperGlue Matches with OpenCV?

Thanks.

0

There are 0 answers