I followed this guide to install opencv (version 3.4.4) and the contrib modules because I want to work with the SIFT algorithm. https://www.pyimagesearch.com/2018/05/28/ubuntu-18-04-how-to-install-opencv/ When I noticed, it was not working as expected after the installation, I deleted the build folder and tried again, but this did not work as well. I imported like this:
import cv2 as cv
I tried to use SIFT (in python 3.6) in the following ways:
sift = cv.SIFT_create()
sift = cv.xfeatures2d.SIFT_create()
sift = cv.SIFT()
sift = cv.xfeatures2d.SIFT()
As this usually results in errors like this: Attribute Error: module cv2 has no attribute 'SIFT_create' (same thing happens for the other 3 options), I figure that I am either using it in an incorrect way or the installation process itself did not work properly.
After this, I found the pip install opencv-contrib-python and used it. With no results at all.
I would really appreciate some hints on how I can make opencv with contrib modules work.
You may have to say
cv2.xfeatures2d_SIFT
or similar. the modules of OpenCV don't necessarily map to python submodules.Since the patent on SIFT expired in 2019, OpenCV moved it back into
features2d
(main repo) fromxfeatures2d
(opencv_contrib repo). Please use the most recent 3.4.x release, or 4.x.