Ask Your Question

XinLi's profile - activity

2020-02-18 21:40:48 -0600 received badge  Teacher (source)
2020-02-18 04:57:05 -0600 received badge  Self-Learner (source)
2020-02-18 04:49:37 -0600 marked best answer I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I solved many problems and finally, cmake, make, sudo make install, but when I run this code:

sift = cv2.xfeatures2d.SIFT_create()


in python, it says

AttributeError: 'module' object has no attribute 'xfeatures2d'


although everything works perfectly well in c++, I can totally use SIFT in c++. I wonder how I can solve this problem so that I'm able to also use SIFT in python.

here is my Cmake config:

cmake -D CMAKE_BUILD_TYPE=RELEASE \

-D CMAKE_INSTALL_PREFIX=/usr/local \

-D OPENCV_EXTRA_MODULES_PATH=/Users/lixin/Desktop/material/opencv/opencv_contrib-3.4.9/modules \

-D BUILD_EXAMPLES=ON \

-D OPENCV_ENABLE_NONFREE=ON \

-D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ ..

In the output of Cmake, I notice something unusual, that xfeatures2d is in both To be built list and Unavailable list but I don't know why:

OpenCV modules:

-- To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto

-- Disabled: world

-- Disabled by dependency: -

-- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java js matlab ovis python3 sfm viz xfeatures2d

-- Applications: tests perf_tests examples apps

-- Documentation: NO

-- Non-free algorithms: YES

However, it goes well in the make and make install process, I can even find these infos:

[ 78%] Built target opencv_xfeatures2d

[ 78%] Built target example_xfeatures2d_surf_matcher

[ 78%] Built target example_xfeatures2d_shape_transformation

[ 78%] Built target example_xfeatures2d_pct_signatures

[ 79%] Built target example_xfeatures2d_pct_webcam

[ 80%] Built target opencv_perf_xfeatures2d

[ 80%] Built target example_xfeatures2d_video_homography

[ 80%] Built target example_xfeatures2d_gms_matcher

[ 80%] Built target opencv_test_xfeatures2d

[ 80%] Built target example_xfeatures2d_bagofwords_classification

opencv_python also builds, but won't work with xfeatures2d though:

[100%] Linking CXX shared module ../../lib/cv2.so

[100%] Built target opencv_python2

somebody please help!! I'm so desperate now....T_T
Also, I would like to know how I can build opencv with both python2 and python3, I've tried several ways but all failed. I am using MacOS, and my python3 is built in Xcode, it seems opencv only compiles with python2 for some reason.. I've tried:
-DPYTHON_DEFAULT_EXECUTABLE
-DPYTHON3_EXECUTABLE
-DPYTHON3_NUMPY_INCLUDE_DIRS
-DPYTHON3_PACKAGES_PATH
-DPYTHON3_LIBRARIES
-DPYTHON3_INCLUDE_DIRS
-D __INSTALL_PATH_PYTHON3
-DBUILD_NEW_PYTHON_SUPPORT=ON
-DBUILD_opencv_python3=ON
-DHAVE_opencv_python3=ON and such. Please HELP!!!

2020-02-18 04:36:39 -0600 commented question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

Problem Solved!!!✌️, @LBerger @berak @supra56 thanks all you guys for help. It is because that xfeatures2d requires boos

2020-02-18 02:14:30 -0600 commented question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

@supra56 thanks for trying to help. I didn't use that option when I tried to build opencv_python3, but still it never bu

2020-02-17 02:19:15 -0600 commented question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

@LBerger I run cv2.__version__ and it shows'3.4.9', and when I move cv2.so to trash then I can't import cv2 any more. no

2020-02-17 02:12:22 -0600 commented question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I do have - DOPENCV_ENABLE_NONFREE=ON in my cmake options. when I run cv2.getBuildInformation(), I get something like th

2020-02-17 01:29:13 -0600 commented question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

@LBerger It's all replaced now.

2020-02-17 01:27:44 -0600 edited question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7 I solved many problems and finally, cmake

2020-02-17 01:22:07 -0600 edited question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7 I solved many problems and finally, cmake

2020-02-17 01:11:04 -0600 edited question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7 I solved many problems and finally, cmake

2020-02-17 01:01:41 -0600 edited question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7 I solved many problems and finally, cmake

2020-02-17 00:59:58 -0600 received badge  Editor (source)
2020-02-17 00:59:58 -0600 edited question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7 I solved many problems and finally, cmake

2020-02-17 00:53:32 -0600 commented question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I found this in one of the links: "upcoming 4.2.0 / 3.4.9 opencv-python release will be the last release which includes

2020-02-16 20:33:43 -0600 asked a question I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7[SOLVED]

I'm compiling opencv3.4.9 and contrib3.4.9. But it doesn't work with python2.7 I solved many problems and finally, cmake