Ubuntu 16.04 Python after install OpenCV 3.1 and OpenCV_contrib 3.1, some extra modules are missing like Tracking and sfm

asked 2017-05-11 05:58:03 -0600

john_turnbull gravatar image

updated 2017-05-11 12:14:01 -0600

After installed OpenCV 3.1 and OpenCV_contrib 3.1, some extra modules are missing like Tracking and sfm, but some can be used like Xfeatures2d. When I try to use command in python 2.7:

Help on module cv2:

NAME cv2

FILE /home/td/.virtualenvs/cv/local/lib/python2.7/site-packages/cv2.so

SUBMODULES Error aruco bgsegm bioinspired cuda datasets detail dnn face fisheye flann freetype ft hdf instr line_descriptor ml motempl multicalib ocl ogl omnidir optflow plot ppf_match_3d rgbd saliency structured_light text videostab viz xfeatures2d ximgproc xphoto

There is no Tracking module and some others. And also when I try to use command:

        import cv2

        tracker = cv2.Tracker_create("MIL")
        Traceback (most recent call last):
        File "", line 1, in
        AttributeError: 'module' object has no attribute 'Tracker_create'

        cv2.Tracker_create
        Traceback (most recent call last):
        File "", line 1, in
        AttributeError: 'module' object has no attribute 'Tracker_create'

        sift = cv2.xfeatures2d
        cv2.xfeatures2d
        <module 'cv2.xfeatures2d' (built-in)>

My Cmake command is:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules ~/opencv-3.1.0 \
    -D PYTHON_EXECUTABLE=~/.virtualenvs/cv1/bin/python \
    -D BUILD_EXAMPLES=ON ..

And the output is:

-- The CXX compiler identification is GNU 5.4.0
-- The C compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected version of GNU GCC: 54 (504)
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Success
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test ...
(more)
edit retag flag offensive close merge delete

Comments

can you add the cmake (console) output to your question ?

(i know, it's scaringly long, but it should contain some helpful explanations, like missing dependancies, failed 3rdparty downloads, etc.)

berak gravatar imageberak ( 2017-05-11 06:06:38 -0600 )edit
1

Thank you, Berak, the output is updated. I checked them before, but I really cannot get any valuable info.

john_turnbull gravatar imagejohn_turnbull ( 2017-05-11 06:25:02 -0600 )edit

It is sooo weird that I have already install opencv master, opencv 3.2 and opencv 3.1 with their extra modules. But it still gave same problem.

john_turnbull gravatar imagejohn_turnbull ( 2017-05-11 06:27:23 -0600 )edit

-- Checking SFM deps... FALSE -- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags

well, you need to install Glog/Gflags for the sfm module, also CERES, if you want to reconstruct anything

  • "After installed OpenCV 3.2 and OpenCV_contrib 3.2, " <--> -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules ~/opencv-3.1.0

version mismatch ?

  • -- packages path: lib/python2.7/site-packages <--> /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so
berak gravatar imageberak ( 2017-05-11 06:38:15 -0600 )edit

so, it installed the newly built cv2.so to lib/python2.7/site-packages (which should contain the tracking module, but not sfm) , but you're using the ros version for the help(cv2) in your question

if you don't ABSOLUTELY need ROS, that would be the 1st thing to axe, it can and will always come in your way. also, when in doubt, prefer latest master branch from github for both opencv and opencv_contrib (versions have to fit exactly).

again, you maybe need a huge spring-cleaning :(

berak gravatar imageberak ( 2017-05-11 06:40:31 -0600 )edit

Thank you so much, berak, I am sorry that I didnt express clearly. This output is the cmake output for opencv 3.1, I install them in different virtualenv, like cv for opencv3.2; cv1 for oepencv3.1.

john_turnbull gravatar imagejohn_turnbull ( 2017-05-11 09:04:44 -0600 )edit

I just remove my ros and reinstall the opencv3.2 again. SAME problem....................................

john_turnbull gravatar imagejohn_turnbull ( 2017-05-11 12:11:52 -0600 )edit

well you won't get the sfm module, unless you install glog, gflags and ceres. no idea about the tracking one.

berak gravatar imageberak ( 2017-05-11 12:15:05 -0600 )edit

Thank you so much, anyway, I just want to use tracking.

john_turnbull gravatar imagejohn_turnbull ( 2017-05-11 12:48:50 -0600 )edit

well, it was build in your last attempt, now you have to find out , what is different in your current one ..

berak gravatar imageberak ( 2017-05-11 12:50:35 -0600 )edit