C++ opencv 3.0 中缺少 contrib 模块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28323077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
contrib module missing in opencv 3.0?
提问by Jayendhar Gautham
I am using OpenCV 3.0 beta.
我正在使用 OpenCV 3.0 测试版。
I tried to create a face recogniser using createLBPHFaceRecognizer(); class as,
我尝试使用 createLBHFaceRecognizer() 创建一个人脸识别器;类为,
**Ptr <FaceRecognizer> model = createLBPHFaceRecognizer();**
the error I have is
我的错误是
**error: 'createLBPHFaceRecognizer' was not declared in this scope**
I have researched and found that the class exists in contrib
module of opencv2
(opencv2/contrib/contrib.hpp) in previous versions of OpenCV
我研究发现该类存在contrib
于以前版本的OpenCV中的opencv2模块(opencv2/contrib/contrib.hpp)中
But this module is not available in opencv 3.0 beta. So where are the recogniser classes defined in opencv 3.0?
但是这个模块在 opencv 3.0 beta 中不可用。那么opencv 3.0中定义的recogniser类在哪里呢?
If they are not defined,how can we add this module in addition to the existing modules?
如果没有定义,我们如何在现有模块之外添加这个模块?
采纳答案by berak
you will have to download and build the opencv_contribrepo.
您必须下载并构建opencv_contrib 存储库。
after running cmake, make, make install,
运行 cmake、make、make install 后,
#include <opencv2/face.hpp>
// note the additional namespace:
cv::Ptr <cv::face::FaceRecognizer> model = cv::face::createLBPHFaceRecognizer();
// proceed as usual
回答by Mahyar
from https://github.com/opencv/opencv_contrib:
来自https://github.com/opencv/opencv_contrib:
- Start cmake-gui
- Select the opencv source code folder and the folder where binaries will be built (the 2 upper forms of the interface)
- Press the configure button. you will see all the opencv build parameters in the central interface
- Browse the parameters and look for the form called OPENCV_EXTRA_MODULES_PATH (use the search form to focus rapidly on it)
- Complete this OPENCV_EXTRA_MODULES_PATH by the proper pathname to the /modules value using its browse button.
- Press the configure button followed by the generate button (the first time, you will be asked which makefile style to use)
- Build the opencv core with the method you chose (make and make install if you chose Unix makfile at step 6)
- 启动 cmake-gui
- 选择opencv源代码文件夹和要编译二进制文件的文件夹(界面上2个表格)
- 按配置按钮。您将在中央界面中看到所有 opencv 构建参数
- 浏览参数并查找名为 OPENCV_EXTRA_MODULES_PATH 的表单(使用搜索表单快速关注它)
- 使用其浏览按钮通过 /modules 值的正确路径名完成此 OPENCV_EXTRA_MODULES_PATH。
- 按配置按钮,然后按生成按钮(第一次,您将被询问使用哪种 makefile 样式)
- 使用您选择的方法构建 opencv 核心(如果您在步骤 6 中选择了 Unix makfile,则 make 和 make install)
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.
要运行,需要添加 contrib 模块的链接器标志以在您的代码/IDE 中使用它们。例如要使用 aruco 模块,将添加“-lopencv_aruco”标志。
回答by Vorac
On my Debian installation
在我的 Debian 安装中
$ dpkg -l libopencv-contrib-dev
ii libopencv-contrib-dev:amd64 3.2.0+dfsg-6 amd64 development files for libopencv-contrib3.2
enables me to use contributed modules with just an additional include. For example:
使我能够使用仅包含额外包含的贡献模块。例如:
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
auto model = cv::face::createLBPHFaceRecognizer();