OpenCV3.0 - module has no attribute SIFT
I am using Ubuntu 12.04. I recently installed OpenCV 3.0 from https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip. I want to do feature matching for which I used the following code:
import numpy as np import cv2 from matplotlib import pyplot as plt MIN_MATCH_COUNT = 10 img1 = cv2.imread('box.png',0) # queryImage img2 = cv2.imread('box_in_scene.png',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) FLANN_INDEX_KDTREE = 0 index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) search_params = dict(checks = 50) flann = cv2.FlannBasedMatcher(index_params, search_params) matches = flann.knnMatch(des1,des2,k=2) # store all the good matches as per Lowe's ratio test. good =  for m,n in matches: if m.distance < 0.7*n.distance: good.append(m) if len(good)>MIN_MATCH_COUNT: src_pts = np.float32([ kp1[m.queryIdx].pt for m in good ]).reshape(-1,1,2) dst_pts = np.float32([ kp2[m.trainIdx].pt for m in good ]).reshape(-1,1,2) M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0) matchesMask = mask.ravel().tolist() h,w = img1.shape pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2) dst = cv2.perspectiveTransform(pts,M) img2 = cv2.polylines(img2,[np.int32(dst)],True,255,3, cv2.CV_AA) else: print "Not enough matches are found - %d/%d" % (len(good),MIN_MATCH_COUNT) matchesMask = None draw_params = dict(matchColor = (0,255,0), # draw matches in green color singlePointColor = None, matchesMask = matchesMask, # draw only inliers flags = 2) img3 = cv2.drawMatches(img1,kp1,img2,kp2,good,None,**draw_params) plt.imshow(img3, 'gray'),plt.show()
I get the following error:
Traceback (most recent call last): File "feature_matching.py", line 11, in <module> sift = cv2.SIFT() AttributeError: 'module' object has no attribute 'SIFT'
Why is SIFT not available in OpenCV 3.0? How do I add SIFT to OpenCV 3.0? Any help would be appreciated. Thankyou.
PS. I tried including modules from https://github.com/Itseez/opencv_contrib
$ cd <opencv_build_directory> $ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory> $ make -j5 $ make install
Where did SIFT and SURF go in OpenCV 3?, SIFT_create(). Traceback (most recent call last):. File "<stdin>", line 1, in <module>. AttributeError: 'module' object has no attribute 'SIFT_create'. > yes, you need to build the opencv_extra modules (esp. xfeatures2d). don't forget to run make install after the cmake/make step (your new python module has to get copied over to python/lib/sitelibs)
Another possibility (and the easiest one I found!) is to install the 2.4.9 release which already include SIFT and SURF algorithm. You just have to do then
import cv2 sift = cv2.SIFT() (...)
OpenCV3.0 - module has no attribute SIFT - opencv - html, SIFT() AttributeError: 'module' object has no attribute 'SIFT' Why is SIFT not available in OpenCV 3.0? How do I add SIFT to OpenCV 3.0? Any help would be Module object has no attribute xfeatures2d. – Clive Sep 9 '14 at 12:11 you can do help(cv2) to see, what made it into cv2.pyd this time. if xfeatures2d is missing, there must have been build errors ? there were issues with the cudaarithm dependancy. if you build without cuda, you should remove it from the dependancy – berak Sep 9 '14 at 12:24
Because of SIFT and SIRF are patended by theirs creators, these descriptors were moved to opencv_contrib package. In order to use it you need download and install both packages: original and contrib.
cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..
AttributeError: 'module' object has no attribute 'SIFT' · Issue #167 , AttributeError: 'module' object has no attribute 'SIFT' #167 In opencv 3.x, the SIFT and SURF descriptors are part of the xfeatures2d submodule. Try the AttributeError: 'module' object has no attribute 'SIFT' #167. Basilisvirus opened this issue Sep 15, 2018 · 10 comments Comments. Copy link Quote reply
There is a pip source that makes this very easy.
If you have another version of opencv-python installed use this command to remove it to avoid conflicts:
pip uninstall opencv-python Then install the contrib version with this:
pip install opencv-contrib-python SIFT usage:
import cv2 sift = cv2.xfeatures2d.SIFT_create()
source:Can't use SURF, SIFT in OpenCV
'module' object has no attribute 'SIFT', Hello. I've installed openCV 2.4.7 in Windows 8, and I'm trying to use it in Python 2.7. My IDE is Visual Studio 2010. This is my code: import Where did SIFT and SURF go in OpenCV 3? by Adrian Rosebrock on July 16, 2015 If you’ve had a chance to play around with OpenCV 3 (and do a lot of work with keypoint detectors and feature descriptors) you may have noticed that the SIFT and SURF implementations are no longer included in the OpenCV 3 library by default.
xfeatures2d - Questions, module 'cv2' has no attribute 'xfeatures2d' · python OpenCV Best way to match the spot patterns SIFT between 1 image and dataset (2 images) · SIFT · c++. 42 questions Tagged. xfeatures2d Python3 : AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d' Compute Dense SIFT features in OpenCV 3.0. SIFT.
Attributeerror module cv2 cv2 has no attribute face python, attribute called SIFT, but because OpenCV no longer has it, I get this error: Traceback (most recent call last): File "compare.py", line 11, in <module> sift = cv2. System information (version) OpenCV => 3.1 Operating System / Platform => Mac OS latest Compiler => Jupyter Notebook, python Detailed description I cannot use the CV2.sift() object.
How do I get SIFT back into OpenCV? : Python, 0. Missing SIFT descriptors. by JM100in Kaggle Forum a year ago. When I try to this error appear: AttributeError: module 'cv2.cv2' has no attribute 'SIFT'. Opencv 3.0-module object has no attribute 'xfeatures2d' (1) I am writing down an answer to my own question, as it might help somebody fixing the same issue. The opencv package I was trying for was downloaded from opencv official website.