我正在按照此处的说明为 Java 开发设置 OpenCV。 http://docs.opencv.org/trunk/doc/tutorials/introduction/desktop_java/java_dev_intro.html . 我正在使用 Mac OS X 10.10.1 和 Java 1.8.0_25。
我无法使用 cmake 将 Java 添加到“待构建”列表中,这是创建 Java 开发所需的 Java 链接 native 库和 jar 文件的先决条件。
我收到的警告如下。我不知道如何解释这个输出,我不明白我是否需要对警告做出回应。错误中没有提到 Java。任何人都可以帮助我超越这个阶段吗?
[注意:我在 OpenCV 论坛上提出过这个问题,但没有得到回复。]
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at apps/haartraining/CMakeLists.txt:37 (add_library): Policy CMP0038 is not set: Targets may not link directly to themselves. Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
Target "opencv_haartraining_engine" links to itself. This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev): Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake --help-policy CMP0042" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
opencv_python
This warning is for project developers. Use -Wno-dev to suppress it.
最佳答案
我建议使用 Homebrew 安装 OpenCV .它可以让你免去很多麻烦。安装后 Homebrew就像输入这两行一样简单。 (ffmpeg 是可选的,我需要它来制作视频)
brew tap homebrew/science
brew install opencv --with-ffmpeg --with-java
之后,您只需将文件添加到此位置:
/usr/local/Cellar/opencv/VERSION_NUMBER/share/OpenCV/java
到您的项目。
并且不要忘记在您的代码中加载库:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
关于java - 在 OS X 上设置 OpenCV Java 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27774007/