Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenCV Computer Vision with Java

You're reading from   OpenCV Computer Vision with Java Create multiplatform computer vision desktop and web applications using the combination of OpenCV and Java

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781783283972
Length 174 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Daniel Lelis Baggio Daniel Lelis Baggio
Author Profile Icon Daniel Lelis Baggio
Daniel Lelis Baggio
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Setting Up OpenCV for Java FREE CHAPTER 2. Handling Matrices, Files, Cameras, and GUIs 3. Image Filters and Morphological Operators 4. Image Transforms 5. Object Detection Using Ada Boost and Haar Cascades 6. Detecting Foreground and Background Regions and Depth with a Kinect Device 7. OpenCV on the Server Side Index

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.

You have been reading a chapter from
OpenCV Computer Vision with Java
Published in: Jul 2015
Publisher:
ISBN-13: 9781783283972
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image