Install OpenCV 3.0 with additional modules (sift, surf ...) for python

I tried to install (many times) OpenCV 3.0 for python with an additional package (sift, surf ...), but I always fail, I really get stuck. I tried in the main environment and then in virtual,

Here is what I did:

cd git git clone https://github.com/Itseez/opencv_contrib.git cd .. wget https://github.com/Itseez/opencv/archive/3.0.0-beta.zip unzip 3.0.0-beta.zip cd opencv-3.0.0-beta/ mkdir release cd release/ workon OCR cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/home/jbd/src/opencv-3.0.0b -D OPENCV_EXTRA_MODULES_PATH=/home/jbd/git/opencv_contrib/modules -D BUILD_opencv_python3=ON -D PYTHON2_EXECUTABLE=/home/jbd/.virtualenv/OCR/bin/python -D PYTHON_INCLUDE_DIR=/home/jbd/.virtualenv/OCR/include/python2.7 -D PYTHON_LIBRARY=/usr/lib/libpython2.7.so -D PYTHON2_NUMPY_INCLUDE_DIRS=/home/jbd/.virtualenv/OCR/local/lib/python2.7/site-packages/numpy .. make -j7 make install cd ~/.virtualenv/OCR/lib/python2.7/site-packages/ ln -s /home/jbd/src/opencv-3.0.0b/lib/python2.7/site-packages/cv2.so 

No matter how I try to install it, I always get:

Traceback (last last call): File "/ home / jbd / git / ocr / test.py", line 10, in sift = cv2.xfeatures2d.SIFT () AttributeError: the object 'module' does not have the attribute 'SIFT'

with:

 import numpy as np import cv2 sift = cv2.xfeatures2d.SIFT() 

If someone sees where I'm wrong ...

thanks a lot

+6
source share
1 answer
 >>> help(cv2.xfeatures2d) 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 

with opencv3.0, you need to use the XXXX_create() function to get an instance so that:

 orb = cv2.ORB_create() 

and

 sift = cv2.xfeatures2d.SIFT_create() sift.detect(...) sift.compute(...) 
+9
source

Source: https://habr.com/ru/post/981151/


All Articles