0

I know this isn't a pure programming question, but I'd like to have a response like https://stackoverflow.com/a/18590112 .

I'd like to know how to build the OpenCV 3.0.0-beta library to use it with Python, with SIFT and SURF functions like seen in the OpenCV documentation, which are a non-free part of the lib, on a Debian Linux operating system, via the command line.

Thanks in advance, and I hope this topic will help in the future all the persons who Googled desperately to find a good tutorial to build this library.

Community
  • 1
  • 1
DinoDee
  • 3
  • 1
  • 2

1 Answers1

1

with opencv3.0, sift and surf have been moved to a opencv_contrib repo, also, you will need to build the whole thing from src. so:

  1. fork/clone/download that. take your time with the readme there.
  2. add it to your cmake settings in the main opencv repo: cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>

  3. (re-)build: cmake, make, make-install.

  4. if all went well, you can try it:


>>> import cv2
>>> help(cv2.xfeatures2d)   # additional namespace !
Help on module cv2.xfeatures2d in cv2:

NAME
    cv2.xfeatures2d

FILE
    (built-in)

FUNCTIONS
    SIFT_create(...)
        SIFT_create([, nfeatures[, nOctaveLayers[, contrastThreshold[, edgeThreshold[, sigma]]]]]) -> retval

    SURF_create(...)
        SURF_create([, hessianThreshold[, nOctaves[, nOctaveLayers[, extended[,upright]]]]]) -> retval


>>> sift = cv2.xfeatures2d.SIFT_create()
>>> sift.detect(...)
berak
  • 39,159
  • 9
  • 91
  • 89
  • come back, if you encounter problems / find improvements. as you said before: "will help in the future all the persons who Googled desperately". ;) – berak Dec 29 '14 at 18:11
  • @PadraicCunningham , yes (somehow, i don't understand your comment..). also, you can use the contrib repo *only* with opencv3.0 – berak Dec 29 '14 at 18:18
  • just realised when I tried rebuilding the other day I cd'd to the old opencv2 source directory by mistake – Padraic Cunningham Dec 29 '14 at 18:22
  • @PadraicCunningham , so, mix-up of 2.4 and 3.0 src ? – berak Dec 29 '14 at 18:26
  • 1
    yes, don't know how I did not see it before, side effect of looking at the screen for too long! – Padraic Cunningham Dec 29 '14 at 18:28
  • Hum, I'm seeing errors while cmaking. Is Python 3.0 required or can I use Python 2.7 ? – DinoDee Dec 29 '14 at 20:19
  • works fine here using python2.7. what kind of errors ? – berak Dec 29 '14 at 20:21
  • 1
    @berak Nothing, just seen that Python 3 "wasn't detected". But I am compiling, we'll see. – DinoDee Dec 29 '14 at 20:33
  • I finished to build the library, and the example given by @berak works perfectly. However, when I try this code from the documentation : http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.html#py-feature-homography I see that cv2.SIFT() doesn't exist. So, does I just have to replace cv2.SIFT() by cv2.xfeatures2d.SIFT_create() in the code ? – DinoDee Dec 29 '14 at 21:41
  • ^^ aww, there were a couple of recent changes to the api, so the tutorial definitely needs an update. – berak Dec 29 '14 at 21:43
  • 1
    Ha that's why. The documentation isn't up to date. Thanks a lot for your help ! :D – DinoDee Dec 29 '14 at 21:48