opencv, opencv-contrib

 opencv  https://github.com/opencv/opencv/releases (各个版本都有)

 opencv_contrib https://github.com/opencv/opencv_contrib/releases (各个版本都有)

 注意:二者版本要一致!
 

How to build OpenCV with extra modules

You can build OpenCV, so it will include the modules from this repository. Contrib modules are under constant development and it is recommended to use them alongside the master branch or latest releases of OpenCV.

Here is the CMake command for you:

$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5

As the result, OpenCV will be built in the <opencv_build_directory> with all modules from opencv_contrib repository. If you don't want all of the modules, use CMake's BUILD_opencv_* options. Like in this example:

$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -DBUILD_opencv_legacy=OFF <opencv_source_directory>

If you also want to build the samples from the "samples" folder of each module, also include the "-DBUILD_EXAMPLES=ON" option.

If you prefer using the gui version of cmake (cmake-gui), then, you can add opencv_contrib modules within opencv core by doing the following:

  1. start cmake-gui

  2. select the opencv source code folder and the folder where binaries will be built (the 2 upper forms of the interface)

  3. press the configure button. you will see all the opencv build parameters in the central interface

    扫描二维码关注公众号,回复: 4253170 查看本文章
  4. browse the parameters and look for the form called OPENCV_EXTRA_MODULES_PATH (use the search form to focus rapidly on it)

  5. complete this OPENCV_EXTRA_MODULES_PATH by the proper pathname to the <opencv_contrib>/modules value using its browse button.

  6. press the configure button followed by the generate button (the first time, you will be asked which makefile style to use)

  7. build the opencv core with the method you chose (make and make install if you chose Unix makfile at step 6)

  8. to run, linker flags to contrib modules will need to be added to use them in your code/IDE. For example to use the aruco module, "-lopencv_aruco" flag will be added.

 

猜你喜欢

转载自blog.csdn.net/tony2278/article/details/84236621