Bytedeco makes native libraries available to the Java platform by offering ready-to-use bindings generated with the codeveloped JavaCPP technology. This, we hope, is the missing bridge between Java and C/C++.
- JavaCPP [API] – A tool that can not only generate JNI code but also build native wrapper library files from an appropriate interface file written entirely in Java. It can also parse automatically C/C++ header files to produce the required Java interface files.
Prebuilt Java Bindings to C/C++ LibrariesThese are part of a project that we call the JavaCPP Presets. Many coexist in the same GitHub repository, and all use JavaCPP to wrap predefined C/C++ libraries from open-source land. The bindings expose almost all of the relevant APIs and make them available in a portable and user-friendly fashion to any Java virtual machine (including Android), as if they were like any other normal Java libraries. We have presets for the following C/C++ libraries:
- OpenCV – [sample usage] [API] – More than 2500 optimized computer vision and machine learning algorithms
- FFmpeg – [sample usage] [API] – A complete, cross-platform solution to record, convert and stream audio and video
- FlyCapture – [sample usage] [API] – Image acquisition and camera control software
- libdc1394 – [sample usage] [API] – A high-level API for DCAM/IIDC cameras
- OpenKinect – [sample usage] [API] [API 2] – Open source library to use the Xbox Kinect
- librealsense – [sample usage] [API] – Cross-platform camera capture for Intel RealSense F200, SR300 and R200
- videoInput – [sample usage] [API] – A free Windows video capture library
- ARToolKitPlus – [sample usage] [API] – Marker-based augmented reality tracking library
- Chilitags – [sample usage] [API] – Robust fiducial markers for augmented reality and robotics
- flandmark – [sample usage] [API] – Open-source implementation of facial landmark detector
- HDF5 – [sample usage] [API] – Makes possible the management of extremely large and complex data collections
- MKL – [sample usage] [API] – The fastest and most-used math library for Intel-based systems
- OpenBLAS – [sample usage] [API] – An optimized BLAS library based on GotoBLAS2 1.13 BSD version, plus LAPACK
- ARPACK-NG – [sample usage] [API] – Collection of subroutines designed to solve large scale eigenvalue problems
- CMINPACK – [sample usage] [API] – For solving nonlinear equations and nonlinear least squares problems
- FFTW – [sample usage] [API] – Fast computing of the discrete Fourier transform (DFT) in one or more dimensions
- GSL – [sample usage] [API] – The GNU Scientific Library, a numerical library for C and C++ programmers
- LLVM – [sample usage] [API] – A collection of modular and reusable compiler and toolchain technologies
- libpostal – [sample usage] [API] – For parsing/normalizing street addresses around the world
- Leptonica – [sample usage] [API] – Software useful for image processing and image analysis applications
- Tesseract – [sample usage] [API] – Probably the most accurate open source OCR engine available
- Caffe – [sample usage] [API] – A fast open framework for deep learning
- CUDA – [sample usage] [API] – Arguably the most popular parallel computing platform for GPUs
- MXNet – [sample usage] [API] – Flexible and efficient library for deep learning
- TensorFlow – [sample usage] [API] – Computation using data flow graphs for scalable machine learning
- ALE – [sample usage] [API] – The Arcade Learning Environment to develop AI agents for Atari 2600 games
- LiquidFun – [sample usage] [API] – 2D physics engine for games
- Skia – [sample usage] [API] – A complete 2D graphic library for drawing text, geometries, and images
- Systems – [sample usage] [API] – To call native functions of operating systems (glibc, XNU libc, Win32, etc)
- Add here your favorite C/C++ library, for example: Caffe2, OpenNI, OpenMesh, PCL, etc. Read about how to do that.
We will add more to this list as they are made, including those from outside the bytedeco/javacpp-presets repository.
Projects Leveraging the Presets Bindings
- JavaCV [API] – Library based on the JavaCPP Presets that depends on commonly used native libraries in the field of computer vision to facilitate the development of those applications on the Java platform. It provides easy-to-use interfaces to grab frames from cameras and audio/video streams, process them, and record them back on disk or send them over the network.
- JavaCV Examples – Collection of examples originally written in C++ for the book entitled OpenCV 2 Computer Vision Application Programming Cookbook by Robert Laganière, but ported to JavaCV and written in Scala.
- ProCamCalib – Sample JavaCV application that can perform geometric and photometric calibration of a set of video projectors and color cameras.
- ProCamTracker – Another sample JavaCV application that uses the calibration from ProCamCalib to implement a vision method that tracks a textured planar surface and realizes markerless interactive augmented reality with projection mapping.
More Project Information
See the developer site on GitHub for more general information about the Bytedeco projects.
After more than half a year, we are finally making a release! You can obtain the new version 1.2 at the usual places on GitHub and the Maven Central Repository for JavaCPP, JavaCPP Presets, JavaCV, ProCamCalib, and ProCamTracker. For Scala users, Lloyd Chan has also contributed sbt-javacpp and sbt-javacv, offering them easy-to-use plugins for sbt. Thanks to Vince Baines, this release also contains a few binaries for the
linux-armhf platform, which work on most Raspberry Pi devices, among others. We also hope to have continuous integration (CI) set up before long to provide a larger selection of prebuilt binaries on all platforms for non-release versions as well.
With regards to deep learning, we realized last year that JavaCPP had the characteristics of something that was in demand especially in that field, that is to say an easy way to access native libraries from an efficient platform like Java: Java meets Caffe, deep learning in perspective. Since then, Samuel has switched jobs and now works for Skymind, integrating JavaCPP, the JavaCPP Presets, and JavaCV into ND4J and Deeplearning4j, as well as pursuing other avenues, such as maintaining not only bindings for Caffe and cuDNN, but also for MXNet and TensorFlow, among others. Many thanks to Adam Gibson and Chris Nicholson for their trust! I am sure we will achieve great things together.
That said, to attain accuracies higher than traditional methods, deep learning requires a lot of data. That makes it a good candidate for data processing in big data applications. Naturally, they consume large amounts of memory, but Java cannot access arrays larger that can be indexed with a 32-bit
int variable. This is an inherit limitation of the JVM. Given that Hadoop on Java is the de facto standard when it comes to big data applications, it makes sense to have a solution to that limitation. To support 64-bit indexing, we have thus extended the
capacity fields of the
Pointer class to
long. Moreover, since standard NIO buffers do not support
long indexing, we provide a new backend for the
indexer package using
sun.misc.Unsafe. Indexing memory with
long variables represents a fundamental shift in the API, so it might break some existing code, but nothing too dramatic, we hope. On the brighter side, performance on 64-bit architectures is not affected.
Indexer also now implements
AutoCloseable, to obtain the same benefit as with
Pointer and try-with-resources constructs. For applications that cannot take advantage of this for memory management purposes,
Pointer now also tracks the amount of memory allocated as reported by the
capacity field. This does not work for most native libraries, more work would be required to query memory consumption from the operating system, but it works when allocating arrays of simple types with
allocateArray(). Once memory consumption tracked this way reaches
Pointer.maxBytes, the allocator will do its best to reclaim memory by calling
System.gc(), waiting a bit, and retrying a few times in a loop.
That about covers the essential changes in this release, but other things have been fixed and updated too, so we invite you to check the changelogs and to contact us through the mailing list from Google Groups, issues on GitHub, or the chat room at Gitter, for any questions that you may have. Together, let’s make the future happen!