OpenCV的(JavaCV)VS OpenCV的(C / C ++接口) [英] OpenCV (JavaCV) vs OpenCV (C/C++ interfaces)

查看:412
本文介绍了OpenCV的(JavaCV)VS OpenCV的(C / C ++接口)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否使用JavaCV时,相对于C / C ++实现的OpenCV会有较上一组给定的机器的显著速度的性能优势。

I am just wondering whether there would be a significant speed performance advantage relatively on a given set of machines when using JavaCV as opposed to the C/C++ implementation of OpenCV.

请纠正我,如果我错了,但我的理解是,C / C ++实现的OpenCV是更接近机器,其中,作为Java实现OpenCV的,的javac,将有一个轻微的速度性能劣势(毫秒)作为会有一台虚拟机转换源$ C ​​$ C到字节code然后把它转换成机器code。然而,随着C / C ++,它就会被转换成直机code,因此不进行虚拟机的开销的中间步骤。

Please correct me if I am wrong, but my understanding is that the c/c++ implementation of opencv is closer to the machine where as the Java implementation of OpenCV, JavaC, would have a slight speed performance disadvantage (in milliseconds) as there would be a virtual machine converting your source code to bytecode which then gets converted to machine code. Whereas, with c/c++, it gets converted straight to machine code and thus doesn't carry that intermediary step of the virtual machine overhead.

如果我犯了错误,请不要杀我这里;我刚学,并欢迎建设性的批评。

Please don't kill me here if I made mistakes; I am just learning and would welcome constructive criticism.

感谢您

推荐答案

我想两件事情添加到@的EJB的回答。

I'd like to add a couple of things to @ejbs's answer.

首先,你关心两个独立的问题:

First of all, you concerned 2 separate issues:


  1. 的Java与C ++的性能

  2. OpenCV的VS JavaCV

的Java与C ++ 性能是一个很长很长的故事。一方面,的 C ++程序的被编译到的高度优化的本地code 的。他们迅速启动并没有停下垃圾收集或其他VM职责跑得快所有的时间(如Java做的)。在另一方面,一旦编译程序在C ++中无法改变的,他们都跑哪台机器不管,而 Java字节code 的编译的刚刚在时间,并始终的的处理器架构优化的运行它们。在当今世界,有这么多不同的设备(和处理器架构),这可能是真的显著。此外,一些JVM(如甲骨文热点)可以优化甚至code,它已经被编译为本地code! VM收集有关程序执行,不时试图改写code以这样的方式,它是优化数据的这个特定的执行的。因此,在这种复杂环境的唯一真正的方法来比较不同的编程语言实现的性能是刚刚运行它们,看看结果。

Java vs. C++ performance is a long, long story. On one hand, C++ programs are compiled to a highly optimized native code. They start quickly and run fast all the time without pausing for garbage collection or other VM duties (as Java do). On other hand, once compiled, program in C++ can't change, no matter on what machine they are run, while Java bytecode is compiled "just-in-time" and is always optimized for processor architecture they run on. In modern world, with so many different devices (and processor architectures) this may be really significant. Moreover, some JVMs (e.g. Oracle Hotspot) can optimize even the code that is already compiled to native code! VM collect data about program execution and from time to time tries to rewrite code in such a way that it is optimized for this specific execution. So in such complicated circumstances the only real way to compare performance of implementations in different programming languages is to just run them and see the result.

的OpenCV与JavaCV 是另一回事。首先,你需要了解这些库背后的技术堆栈。

OpenCV vs. JavaCV is another story. First you need to understand stack of technologies behind these libraries.

OpenCV的是在英特尔研究实验室在1999年最初创建,并用C编写自那时以来,它改变了维护好几倍,成为开源和达到第3版(即将发布)。目前,图书馆的核心是用C ++与Python中常用的接口和其他编程语言的一些包装的。

OpenCV was originally created in 1999 in Intel research labs and was written in C. Since that time, it changed the maintainer several times, became open source and reached 3rd version (upcoming release). At the moment, core of the library is written in C++ with popular interface in Python and a number of wrappers in other programming languages.

JavaCV是这样的包装中的一个。所以在大多数情况下,当您运行JavaCV实际使用OpenCV的过程序,只需通过另一个接口调用它。但JavaCV提供比只有一个对一绕OpenCV的包装更。事实上,它捆绑的图像处理库,包括FFmpeg的,OpenKinect和其他的整数。 (注意,在C ++中可以绑定这些库太)。

JavaCV is one of such wrappers. So in most cases when you run program with JavaCV you actually use OpenCV too, just call it via another interface. But JavaCV provides more than just one-to-one wrapper around OpenCV. In fact, it bundles the whole number of image processing libraries, including FFmpeg, OpenKinect and others. (Note, that in C++ you can bind these libraries too).

所以,一般来说,它不会不管你使用的是什么 - OpenCV的或JavaCV,你会得到几乎相同的性能。它更多的取决于你的主要任务 - 它是Java或C ++哪个更适合您的需求。

So, in general it doesn't matter what you are using - OpenCV or JavaCV, you will get just about same performance. It more depends on your main task - is it Java or C++ which is better suited for your needs.

有是关于性能的一种更重要的一点。使用OpenCV的(直接或通过包装),有时你会发现,OpenCV函数由几个数量级克服了其他实现。这是因为,在其核心大量使用低级别优化的。例如,OpenCV中的<一个href=\"http://docs.opencv.org/modules/imgproc/doc/filtering.html#void%20filter2D%28InputArray%20src,%20OutputArray%20dst,%20int%20ddepth,%20InputArray%20kernel,%20Point%20anchor,%20double%20delta,%20int%20borderType%29\">filter2D功能是<一个href=\"http://docs.opencv.org/modules/imgproc/doc/filtering.html#void%20filter2D%28InputArray%20src,%20OutputArray%20dst,%20int%20ddepth,%20InputArray%20kernel,%20Point%20anchor,%20double%20delta,%20int%20borderType%29\">SIMD-accelerated因此可以并行处理多个数据集。当它涉及到计算机视觉,常用功能的优化等容易导致显著加速。

There's one more important point about performance. Using OpenCV (directly or via wrapper) you will sometimes find that OpenCV functions overcome other implementations by several orders. This is because of heavy use of low-level optimizations in its core. For example, OpenCV's filter2D function is SIMD-accelerated and thus can process several sets of data in parallel. And when it comes to computer vision, such optimizations of common functions may easily lead to significant speedup.

这篇关于OpenCV的(JavaCV)VS OpenCV的(C / C ++接口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆