Sam
Sam

Reputation: 12049

OpenCV ORB descriptor: TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)

I followed this simple OpenCV Feature Matching example exactly:

import cv2

img = cv2.imread('box.png',0) # queryImage
orb = cv2.ORB()               # Initiate ORB detector

# find the keypoints and descriptors with ORB
kp1, des1 = orb.detectAndCompute(img, None)

and have been getting the following error:

TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)

I'm using OpenCV 3.3.1

Upvotes: 21

Views: 30377

Answers (3)

sameer maurya
sameer maurya

Reputation: 121

cv2.ORB_create() will do the job I think

Upvotes: 6

Kaolin Fire
Kaolin Fire

Reputation: 2521

Note the python structures change "frequently" (in internet history years anyway). It's a good idea to pay attention to version.

Go here to find the right link: https://docs.opencv.org/

3.1.1 --> 3.1.0 --> https://docs.opencv.org/3.1.0/ ( OpenCV-Python Tutorials --> https://docs.opencv.org/3.1.0/d6/d00/tutorial_py_root.html ) ... not as pretty as that (old) readthedocs site, but more accurate. :)

Upvotes: 3

Sam
Sam

Reputation: 12049

This is a OpenCV version compatibility issue. Just use cv2.ORB_create() instead of cv2.ORB().

The code should look like:

import cv2

img = cv2.imread('box.png',0) # queryImage
orb = cv2.ORB_create()        # Initiate SIFT detector

# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img, None)

Upvotes: 61

Related Questions