Ask Your Question
0

3.0.0-Python cv2 module cannot find SIFT/SURF/ORB

asked 2014-12-30 22:04:04 -0500

zrinker gravatar image

The OpenCV-3.0.0-Python tutorial just told us we can just use 'cv2.ORB()' to create the ORB detector like this:

import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('simple.jpg',0)
# Initiate STAR detector
orb = cv2.ORB()

However, the Python interpreter reported error: 'module' object has no attribute 'ORB'
I used 'help(cv2)' to explore the module and found no module or functions like SIFT/SURF/ORB.
Somebody said the SIFT/SURF/ORB may be moved to xfeatures2d in opencv-contrib since 3.0.0. So I built opencv-contrib and used help(cv2.xfeatures2d) but found nothing but 2 functions: SIFT_craete() and SURF_create().

I just ran the codes in tutorial but came up with a lot of trouble and I am going to be crazy.
Thanks for any help!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-12-31 02:47:45 -0500

berak gravatar image

updated 2014-12-31 02:49:43 -0500

opencv's api is changing rapidly, and that tutorial might need an update.

you already have found cv2.xfeatures2d.SURF_create(), and it's similar with ORB,MSER,AKAZE, or GFTTDetector, there is a _create() method for all of them, which gives you an instance:

>>> orb = cv2.ORB_create()
>>> help(orb)
...
 |  Methods inherited from Feature2D:
 |
 |  compute(...)
 |      compute(image, keypoints[, descriptors]) -> keypoints, descriptors
 |
 |  defaultNorm(...)
 |      defaultNorm() -> retval
 |
 |  descriptorSize(...)
 |      descriptorSize() -> retval
 |
 |  descriptorType(...)
 |      descriptorType() -> retval
 |
 |  detect(...)
 |      detect(image[, mask]) -> keypoints
 |
 |  detectAndCompute(...)
 |      detectAndCompute(image, mask[, descriptors[, useProvidedKeypoints]]) -> keypoints, descriptors
 |
 |  empty(...)
 |      empty() -> retval
...

or SIFT:

>>> img = cv2.imread('simple.jpg',0)
>>> sift = cv2.xfeatures2d.SIFT_create()
>>> sift.detect(img)
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2014-12-30 21:54:03 -0500

Seen: 12,970 times

Last updated: Dec 31 '14