如何在OS X上使用额外的模块编译OpenCV? [英] How to compile OpenCV with extra modules on OS X?
问题描述
我以前在本指南,该指南主要由以下步骤组成:
I've previously compiled OpenCV 3.0 successfully following this guide, which essentially consists of the following steps:
- 下载所有先决条件(XCode,命令行工具,CMake和OpenCV源代码)
- 通过配置CMake(通过gui)来构建静态库:
- 取消选中 BUILD_SHARED_LIBS
- 取消选中BUILD_TESTS
- 将SDK路径添加到CMAKE_OSX_SYSROOT(如果重要的话,我使用了
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
). - 将x86_64添加到CMAKE_OSX_ARCHITECTURES (重点是我,这似乎是问题所在,我确定我已经遵循了此步骤)
- 取消选中WITH_1394
- 取消选中WITH_FFMPEG
- Download all the prerequisites (XCode, Command Line Tools, CMake and OpenCV source)
- Build static libs by configuring CMake (via gui) with:
- Uncheck BUILD_SHARED_LIBS
- Uncheck BUILD_TESTS
- Add an SDK path to CMAKE_OSX_SYSROOT (if it matters, I used
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
). - Add x86_64 to CMAKE_OSX_ARCHITECTURES (emphasis mine, this seems to be the issue, I'm sure I've followed this step)
- Uncheck WITH_1394
- Uncheck WITH_FFMPEG
仅上述所有方法都可以正常工作.
All of the above alone works fine.
我现在正在寻找使用其他模块编译OpenCV.根据他们的自述文件,它应该很简单,只需将
OPENCV_EXTRA_MODULES_PATH
填写到CMake中的< opencv_contrib>/modules
,然后照常进行构建即可.I'm now looking to compile OpenCV with the extra modules. According to their read-me it should be as simple as filling out
OPENCV_EXTRA_MODULES_PATH
to<opencv_contrib>/modules
in CMake and then building as usual.我按照上面概述的步骤添加了参数,但是,当尝试在程序中使用其他模块之一(即
cv :: ximgproc :: createStructuredEdgeDetection
时),构建OpenCV成功了很重要),编译时出现以下错误:I followed the steps outlined above with the added parameter and building OpenCV succeeds, however, when trying to use one of the extra modules in a program (namely
cv::ximgproc::createStructuredEdgeDetection
, if it matters), I'm getting the following error when compiling:x86_64体系结构的未定义符号:
"cv :: ximgproc :: createStructuredEdgeDetection(cv :: String const& ;, cv :: Ptr< cv :: ximgproc :: RFFeatureGetter const>)"
,引用自:
_main in main.o
ld:找不到架构x86_64的符号
clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)Undefined symbols for architecture x86_64:
"cv::ximgproc::createStructuredEdgeDetection(cv::String const&, cv::Ptr<cv::ximgproc::RFFeatureGetter const>)"
, referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)我已包含标题,其中应包含以上内容:
I've included the header which should include the above:
#include <opencv2/ximgproc.hpp>
我正在通过XCode进行编译,在其中我设置了
/usr/local/include
的附加头搜索路径和/usr/local/lib <的库搜索路径/code>该项目,我在这里遗漏了什么吗?
I'm compiling via XCode, where I've set an additional header search path of
/usr/local/include
and a library search path of/usr/local/lib
for the project, am I missing something here?标准OpenCV功能正常.
Standard OpenCV functionality works fine.
可能是什么问题,我将如何解决?
What could be the issue and how would I go about solving it?
推荐答案
OpenCV contrib模块已正确构建.
OpenCV contrib modules are built correctly.
您只需要将contrib库添加到您的依赖项中,在这种情况下,添加:
-lopencv_ximgproc
.You just need to add the contrib libs to your dependencies, in this case adding:
-lopencv_ximgproc
.所有可用的库都可以在
< OPENCV_DIR>/install/
文件夹下找到.例如.我的32位vc12静态版本中的< OPENCV_DIR>/install/x86/vc12/staticlib
文件夹中.All available libs can be found under
<OPENCV_DIR>/install/
folder. E.g. in my 32bit vc12 static build are in<OPENCV_DIR>/install/x86/vc12/staticlib
folder.这篇关于如何在OS X上使用额外的模块编译OpenCV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!