官术网_书友最值得收藏!

Getting OpenCV for Java development

The first thing to notice when working with OpenCV for Java development is that OpenCV is a C++ library that should be compiled with operating system- specific compilers. The native code that would be generated is platform-dependent. So, the native Linux code won't run in Windows, neither will the Android native code run in OSX. This sounds very different from the bytecode generated for Java, which is executed by an interpreter in any platform. In order to get the native code running in a Java Virtual Machine (JVM), one needs the so called Java Native Interface (JNI). This way, the native code will be required for each platform that your application is going to be run on.

It is important to understand that JNI is a native programming interface. It allows the Java code that runs inside a JVM to interoperate with the applications and libraries written in programming languages such as C, C++, and assembly. Since it bridges the gap between Java and other languages, it needs to convert datatypes from these languages, as well as to create some boilerplate code. Curious readers should refer to the gen_java.py script, located in the modules/java/generator folder, which automates most of this work. Lucky Windows users get compiled binaries, which means source C++ OpenCV code, compiled with Windows compilers into native code that runs only on Windows, from OpenCV packages. Users from other operating systems will need to build binaries from the source code, although one can make that in Windows as well. In order to download compiled binaries, we should get version 2.4.4 or higher of the OpenCV Windows package from the OpenCV SourceForge repository, which is located at http://sourceforge.net/projects/opencvlibrary/files/.

Note

Notice that the prebuilt files needed for Java development are located at opencv/build/java/. For instance, if you are working with version 3.0.0 OpenCV, you should see files containing the Java interface in opencv-300.jar and in the x86 and x64 native dynamic libraries, which contains the Java bindings in x86/opencv_java300.dll and x64/opencv_java300.dll.

主站蜘蛛池模板: 灵璧县| 惠安县| 永康市| 恩施市| 谢通门县| 正定县| 灌南县| 如皋市| 香港| 河东区| 岳普湖县| 根河市| 克东县| 关岭| 渭源县| 彝良县| 建宁县| 隆化县| 南木林县| 北宁市| 浏阳市| 宁夏| 长治市| 平塘县| 平潭县| 哈巴河县| 县级市| 开化县| 德保县| 府谷县| 治多县| 嵊州市| 资阳市| 阜城县| 商河县| 丹凤县| 左云县| 昆山市| 缙云县| 大丰市| 嘉荫县|