2

I have a problem in python opencv!

I want to use SIFT algorithm which is not a default algorithm in opencv package. So I have to build OpenCV with extra modules as bellow:

You can build OpenCV, so it will include the modules from this repository. Here is the CMake command for you:

$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
$ make install

I did all these steps and it was successfully build. But I'm getting error when I call sub modules of opencv (e.g. xfeatures2d, objdetect). I tried using following code;

$ import cv2
$ x = cv2.xfeatures2d()

It gives me error that "module' object has no attribute 'xfeatures2d'".

Do you have any ideas?

7
  • 1
    Possible duplicate of Opencv 3.0 - module object has no attribute 'xfeatures2d' Commented Apr 12, 2016 at 16:20
  • @Mitty can you please tell me how I can find opencv_source_directory? or what it is? so that I can use Cmake GUI! Commented Apr 12, 2016 at 16:29
  • Check if you have followed the installation instructions here, github.com/Itseez/opencv_contrib Commented Apr 12, 2016 at 16:33
  • And which OS are you using?. Commented Apr 12, 2016 at 16:34
  • the link that you gave I have read several times. I want exactly to know what they mean by opencv_source_directory? what should I give there? please help.. Commented Apr 12, 2016 at 16:40

1 Answer 1

2
  1. Download opencv_contrib from here
  2. Download opencv from here
  3. Now create a new directory called opencv_build
  4. Now go to opencv_build directory
  5. Here <opencv_contrib> points to downloaded folder from step 1
  6. And <opencv_source_directory> points to downloaded folder from step 2
  7. Substitute their paths in your cmake command.
Sign up to request clarification or add additional context in comments.

1 Comment

opencv and opencv_contrib have to be in opencv_build folder?