Cant get SIFT to work with opencv_contrib in Python

asked 2014-11-10 18:27:17 -0600

max2me gravatar image

Hi guys,

I'm using Python 2.7

I retrieved latest source code for main branch of opencv3 & latest one for opencv_contrib. I followed instructions and got both built. I'm able to run all of the examples from

http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_table_of_contents_feature2d/py_table_of_contents_feature2d.html except those involving SIFT detector.

When I run my code (shown below) I get

sift = cv2.SIFT()
AttributeError: 'module' object has no attribute 'SIFT'

Code:

import numpy as np
import cv2
from matplotlib import pyplot as plt

img1 = cv2.imread('images/1.jpg',0)          # queryImage
img2 = cv2.imread('images/2.jpg',0) # trainImage

# Initiate SIFT detector
sift = cv2.SIFT()

# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)

# BFMatcher with default params
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)

List of libraries in site-packages folder does include opencv_xfeatures2d300.dll (which I assume has SIFT algorythm I need).

Please help, I tried everything I could find and cannot make it work :(

edit retag flag offensive close merge delete