user5538206
user5538206

Reputation:

add extra modules to opencv python?

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?

Upvotes: 2

Views: 6457

Answers (1)

Mitty
Mitty

Reputation: 340

  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.

Upvotes: 2

Related Questions