安装额外的模块openCV后,跟踪器未定义

时间:2019-01-17 09:23:35

标签: c++ opencv codeblocks opencv-contrib

我目前正在尝试让OpenCV与Linux(Ubuntu 16.04),cmake 3.5.1上的OpenCV额外模块(尤其是跟踪模块)一起使用 我从https://opencv.org/releases.html下载了3.4.5版的OpenCV,并从https://github.com/opencv/opencv_contrib/releases/tag/3.4.5下载了OpenCV contrib 3.4.5。 然后,我遵循了Linux的OpenCV官方文档中的教程:https://docs.opencv.org/3.4.5/d7/d9f/tutorial_linux_install.html

我在openCV上创建了一个构建目录,并使用了命令

cmake -DOPENCV_EXTRA_MODULES_PATH=<openCV contrib/modules> <openCV source directory>

此命令后一切正常:

 --   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz 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 js matlab ovis python3 sfm xfeatures2d
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        YES (ver 2.24.30)
--       GThread :                  YES (ver 2.48.2)
--       GtkGlExt:                  NO
--     VTK support:                 YES (ver 5.10.1)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.6)
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
-- 
--   Video I/O:
--     DC1394:                      YES (ver 2.2.4)
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 56.60.100)
--       avformat:                  YES (ver 56.40.101)
--       avutil:                    YES (ver 54.31.100)
--       swscale:                   YES (ver 3.1.101)
--       avresample:                NO
--     GStreamer:                   
--       base:                      YES (ver 0.10.36)
--       video:                     YES (ver 0.10.36)
--       app:                       YES (ver 0.10.36)
--       riff:                      YES (ver 0.10.36)
--       pbutils:                   YES (ver 0.10.36)
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.2.92)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/pgrisart/Documents/opencv-3.4.5/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
--     numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.15.1)
--     install path:                lib/python2.7/dist-packages/cv2/python-2.7
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         /usr/bin/ant (ver 1.9.6)
--     JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
--     Java wrappers:               YES
--     Java tests:                  YES
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pgrisart/Documents/opencv-3.4.5/build

然后

make

sudo make install 

我没有错误

但是当我尝试使用opencv2 / tracking.hpp从文档中获取代码时,却没有。我只有opencv2 / video / tracking。 如果我在https://docs.opencv.org/3.4.5/d2/d0a/tutorial_introduction_to_tracker.html上使用opencv2 / video / tracking运行代码,则跟踪器未定义。

我应该如何重新安装contrib模块才能获得opencv2 / tracking.hpp?我尝试了许多版本的openCV,并完成了许多教程...

谢谢

2 个答案:

答案 0 :(得分:0)

  1. 有关跟踪示例:-DBUILD_EXAMPLES = ON
  2. 高级功能:-DOPENCV_ENABLE_NONFREE = ON
  3. 您需要测试吗?如果否:-DBUILD_TESTS = OFF -DBUILD_PERF_TESTS = OFF

答案 1 :(得分:0)

问题解决了! 我不知道命令行出了什么问题,但是我通过本教程之后的界面下载了软件cmake:https://towardsdatascience.com/how-to-install-opencv-and-extra-modules-from-source-using-cmake-and-then-set-it-up-in-your-pycharm-7e6ae25dbac5 我删除了导致问题的opencv_features2D

然后

make
sudo make install

一切都与opencv2 / tracking.hpp配合使用