如何使用 Java OpenCV

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13288646/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 12:08:23  来源:igfitidea点击:

How to use Java OpenCV

javaimage-processingopencvjavacv

提问by TomSelleck

I am starting my final year project using image processing and was hoping to accomplish something like this. It's a combination of Human and Object detection.

我开始使用图像处理我的最后一年的项目,并希望能够实现像这样。它是人类和物体检测的结合。

I really wanted to do it in Java because I have very little experience in C++.

我真的很想用 Java 来做这件事,因为我在 C++ 方面的经验很少。

I found JavaCVwhich is a wrapper to OpenCV. However, it has very little support and virtually no documentation. So I was going to fall back and try to start using the native OpenCV when I stumbled across thisJavaDoc on the OpenCV homepage for Java OpenCV.

我找到了JavaCV,它是 OpenCV 的包装器。但是,它几乎没有支持,而且几乎没有文档。因此,当我在Java OpenCV 的 OpenCV 主页上偶然发现JavaDoc时,我打算退回并尝试开始使用本机OpenCV。

My question is, how do I install / use this Java version of OpenCV? Has anybody had experience doing this? Does anybody have a better suggestion as to how I should approach this project?

我的问题是,如何安装/使用这个 Java 版本的 OpenCV?有没有人有这样做的经验?有人对我应该如何处理这个项目有更好的建议吗?

Any advice would be appreciated as this has been hanging over me for a while now.

任何建议将不胜感激,因为这已经困扰我一段时间了。

采纳答案by nikhil

You can find instructions to install and use Javacv in link below. http://opencvlover.blogspot.in/2012/04/javacv-setup-with-eclipse-on-windows-7.html

您可以在下面的链接中找到安装和使用 Javacv 的说明。 http://opencvlover.blogspot.in/2012/04/javacv-setup-with-eclipse-on-windows-7.html

You will be able to use java to use all the algorithms available in opencv using javacv.

您将能够使用 java 使用 javacv 使用 opencv 中可用的所有算法。

回答by aalbatross

Just now i installed opencv-2.4.4 with java support it comes out to be easy however for documentation opencv c++ documentations can be used. Similiar documentation can be used for javacv as well.

刚才我安装了带有 Java 支持的 opencv-2.4.4,结果很容易,但是对于文档,可以使用 opencv c++ 文档。类似的文档也可用于 javacv。

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

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

follow the steps given on the page it works fine. Although it supports only for desktop Java if you want for other platform supports use javacv.

按照页面上给出的步骤它工作正常。虽然它只支持桌面 Java 如果你想其他平台支持使用 javacv。

回答by Cristopher Plasma

dear community! Below describe process of installation OpenCV in Linux and eclipse configuration.

亲爱的社区!下面介绍Linux下安装OpenCV和eclipse配置的过程。

CentOS Linux release 7.3.1611

CentOS Linux 版本 7.3.1611

$ yum install opencv-core.x86_64 opencv-devel.x86_64

After install look in /opt/OpenCV/java

安装后查看/opt/OpenCV/java

$ ls -l /usr/share/OpenCV/java/
итого 1040
-rwxr-xr-x 1 user user 739248 фев  5  2017 libopencv_java310.so*
-rw-r--r-- 1 user user 322277 фев  5  2017 opencv-310.jar

In Eclepse you should create "User library" and

在 Ecepse 中,您应该创建“用户库”并

  • Add JAR-file to this library Modify "Native library location" and set path to driver (*.so)
  • 将 JAR 文件添加到此库 修改“本机库位置”并将路径设置为驱动程序 (*.so)

enter image description here

在此处输入图片说明

If you need build library from sources - visit http://www.giuseppeurso.eu/en/how-to-compile-opencv-on-centos-with-java-support/or another sites.

如果您需要从源代码构建库 - 请访问http://www.giuseppeurso.eu/en/how-to-compile-opencv-on-centos-with-java-support/或其他站点。

回答by jlengrand

Do you have a precise reason for using Java?

您有使用 Java 的确切原因吗?

If your main aim is to create a prototype, I'd advise to go for PyOpenCV which is more broadly supported and easier to handle . If your programming skills are limited (for now), I would advise for Python instead of Java. OpenCV supports both. The main reason for choosing Python is that you can do the same in 3 lines of code where 20 lines or so would be needed in Java. The Python bindings for OpenCV are actually easier to get started with, as they are included into the main source.

如果您的主要目标是创建原型,我建议您选择 PyOpenCV,它支持更广泛且更易于处理。如果您的编程技能有限(目前),我建议您使用 Python 而不是 Java。OpenCV 支持两者。选择 Python 的主要原因是您可以在 3 行代码中完成相同的操作,而在 Java 中则需要 20 行左右。OpenCV 的 Python 绑定实际上更容易上手,因为它们包含在主要源代码中。

Here is the doc

这是文档

And if you are on linux and don't need the very laster version you can start working in less than 5 minutes as there are packages ready for you. :) Simply run

如果您使用的是 linux 并且不需要最新版本,您可以在不到 5 分钟的时间内开始工作,因为已经为您准备好了软件包。:) 只需运行

sudo apt-get install libopencv-*
sudo apt-get install python-opencv
sudo apt-get install python-numpy

If you want the last version, there is a bit more work, but also a nice guide

如果你想要最后一个版本,还有更多的工作,但也是一个很好的指南