Search code examples
pythonopencvorb

OpenCV can't draw keypoints


I tried to run the example code shown for ORB in the openCV page. First I had to figure out the problem of cv2.ORB() (changed to cv2.ORB_create(), the after this error, appeared this:

Traceback (most recent call last):

  File "orb.py", line 17, in <module>
    img2 =cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
TypeError: Required argument 'outImage' (pos 3) not found

After doing a lot of things shown in blogs and manuals, I decided to add img to this function img2 =cv2.drawKeypoints(img,kp,img,color=(0,255,0), flags=0) because of the error in pos (3). It finally worked good, but I'd like to know why only runs like this and no the way the official page states.

BR.


Solution

  • It's the syntax of the cv2.drawKeypoints() function, at least for OpenCV 3.x.

    If you execute help(cv2.drawKeypoints) after import cv2, you will get below which is self-explanatory.

    Help on built-in function drawKeypoints:
    
    drawKeypoints(...)
        drawKeypoints(image, keypoints, outImage[, color[, flags]]) -> outImage
    

    The pos(3) is the output image, outImage, to be returned.