在OS X上设置OpenCV Java绑定

时间:2015-01-05 05:41:03

标签: java opencv video-capture

我按照此处的说明设置OpenCV for Java开发。 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。

我无法将Java添加到"要构建" list使用cmake,这是创建Java开发所需的Java链接本机库和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.

1 个答案:

答案 0 :(得分:0)

我建议使用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);