本文介绍了如何与Java在Linux下使用命令行构建的OpenCV?(要去使用它在马preduce)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我想OpenCV的出我的毕业设计。
我有过的Windows环境下取得了一些成功。而由于与Windows包的OpenCV它带有pre-建库,所以我不担心如何构建他们。
但由于该项目是假设在CentOS为每个节点的主机操作系统在集群上运行,我必须知道如何正确地编译和Linux下运行的环境,这些库。

Recently I'm trying OpenCV out for my graduation project.I've had some success under Windows enviroment. And because with Windows package of OpenCV it comes with pre-built libraries, so I don't have to worry about how to build them.But since the project is suppose to run on a cluster with CentOS as host OS for each node, I have to know how to correctly compile, and run these library under Linux enviroment.

我已经设置了一个VirtualBox的虚拟机并在其上安装的Ubuntu 13.04。
但到目前为止,我仍然无法找到一种方法来调整CMakeList的设置,以使Java构建的目标。 (A瓶和一个机库,所以我可以导入和马preduce程序中使用它们)
以下是桌面Java对OpenCV的官方教程

I've set up a VM with VirtualBox and installed Ubuntu 13.04 on it.But so far I still can't find a way to adjust the settings of CMakeList to make Java a build target. (A jar, and a native library so I can import and use them in MapReduce program)Following is the official tutorial of desktop Java for OpenCV

http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html

有关编译的部分是pretty简短。所以,我还是不太明白。
难道是因为我错过了一些Java的依赖?我已经有安装了JVM(JRE-7u7)。
还是因为我没有正确配置CMakeList.txt?

The part about the compiling is pretty brief. So I still can't quite understand it.Is it because I missed some dependency for Java? I've already got JVM(Jre-7u7) installed.Or is it because I didn't configure CMakeList.txt correctly?

下面是我迄今所做的事情,除了它是一个完整的Ubuntu的清洁等。

Here is the things I've done so far, other than that it's a complete clean Ubuntu


  1. 已安装的vim

  2. 安装的G ++

  3. 已安装的CMake

  4. 安装的CMake-诅咒的GUI

  5. 安装java7目录JVM

  6. 下载OpenCV的包装用于Linux

目标环境是群集在CentOS为每个节点的主机操作系统,而该项目是一个马preduce程序。

The target enviroment is Cluster with CentOS as host OS for each node, and the project is a MapReduce program.

先谢谢了。

推荐答案

可能就是你缺少的是蚂蚁,这是一个面向Java构建工具。

Probably what you're missing is ant, which is a java oriented build tool.

当你去:

cmake -D BUILD_SHARED_LIBS=OFF ../opencv-2.4.5/

(即。你在哪里配置为您的机器),检查写着部分的的Java 。这应该说是这样的(可能有不同的路径/版本):

(i.e. where you're configuring the make for your machine), check for the section that says java. It should say something like this (possibly with different paths/versions):

--   Java:
--     ant:                         /usr/bin/ant (ver 1.8.2)
--     JNI:                         /usr/lib/jvm/java-6-openjdk/include /usr/lib/jvm/java-6-openjdk/include /usr/lib/jvm/java-6-openjdk/include
--     Java tests:                  YES

当我第一次跑了CMake的,我有这样的:

When I first ran cmake, I had this:

--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java tests:                  YES

这表明它找不到蚂蚁,因此它并没有创建一个.jar文件。
我简单地使用在资源库中​​的版本:

Which indicated it couldn't find ant, and so it didn't create a .jar file.I simply use the version that's in the repository:

sudo apt-get install ant

我的CMake又跑,用上面的选项,这得到了路径蚂蚁(和我JNI是免费的!)。

I ran cmake again, with the above options, which got the path to ant (and I got JNI for free!).

注意:您可能要仔细比较,因为它会告诉你什么是要建立你的机器上,你可能有一些缺失的库阅读CMake的输出

Note: You probably want to read the output of cmake fairly carefully as it tells you what it's going to build on your machine, and you may have some missing libraries.

如果您发现JNI是人仍下落不明。

cmake的是(主要是?第一?方便?可以作为PTED?间$ P $)寻找jni.h,其中应特别 $ JAVA_HOME /有/ jni.h 所以,你需要$ JAVA_HOME设置为JDK的主文件夹。

cmake is (mostly? first? conveniently? can be interpreted as?) looking for jni.h, which should be specifically $JAVA_HOME/include/jni.h So you need to set $JAVA_HOME to the home folder of your jdk.

我用其中的javac 然后的ls -l 遵循一系列符号链接,找出我在哪里java的1.7安装了。你也可以使用定位jni.h 和工作了树,或者干脆看看周围 / usr / lib目录/ JVM 或类似的。

I used which javac and then ls -l to follow a series of symbolic links, to identify where my java 1.7 install was. You could also use locate jni.h and work up the tree, or simply look around /usr/lib/jvm or similar.

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

您可能要检查你有一对夫妇的这一权利。

You probably want to check that you've got that right with a couple of

ls $JAVA_HOME/bin/javac
/usr/lib/jvm/java-7-openjdk-amd64/bin/javac

ls $JAVA_HOME/include/jni.h
/usr/lib/jvm/java-7-openjdk-amd64/include/jni.h

有趣的是,当我再次运行cmake的命令时,拿起不同的JNI文件夹:

Interestingly when I ran the cmake command again, it picked up a different JNI folder:

--     JNI:                         /usr/lib/jvm/java-7-openjdk-amd64/include /usr/lib/jvm/java-7-openjdk-amd64/include /usr/lib/jvm/java-7-openjdk-amd64/include

一旦你得到的是,运行制作命令。如果你看痴迷,你会看到一堆.java文件滚动过去。无论哪种方式,你会在./bin文件夹中的.jar文件结束。
(在我的情况下,它被称为 OpenCV的-245.jar 因为这是在code我下载的版本)。

Once you've got that, run the make command. If you watch obsessively, you'll see a bunch of .java files trundle past. Either way you'll end up with a .jar file in the ./bin folder.(in my case it's called opencv-245.jar as that's the version of the code I downloaded).

这篇关于如何与Java在Linux下使用命令行构建的OpenCV?(要去使用它在马preduce)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 03:10