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++, bringing compute-intensive science, multimedia, computer vision, deep learning, etc to the Java platform.
Core Technologies
- 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++ Libraries
These 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 from PGR
- Spinnaker – [sample usage] [API] – Image acquisition and camera control software from FLIR
- libdc1394 – [sample usage] [API] – A high-level API for DCAM/IIDC cameras
- OpenKinect – [sample usage] [API] [API 2] – Open source library to use Kinect for Xbox and for Windows sensors
- librealsense – [sample usage] [API] [API 2] – Cross-platform library for Intel RealSense depth and tracking cameras
- 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
- Arrow – [sample usage] [API] – A cross-language development platform for in-memory data
- HDF5 – [sample usage] [API] – Makes possible the management of extremely large and complex data collections
- Hyperscan – [sample usage] [API] – High-performance regular expression matching library
- LZ4 – [sample usage] [API] – Extremely fast compression algorithm
- MKL – [sample usage] [API] – The fastest and most-used math library for Intel-based systems
- oneDNN – [sample usage] [API] [API 2] – Intel Math Kernel Library for Deep Neural Networks (DNNL)
- 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
- CPython – [sample usage] [API] – The standard runtime of the Python programming language
- NumPy – [sample usage] [API] – Base N-dimensional array package
- SciPy – [sample usage] [API] – Fundamental library for scientific computing
- Gym – [sample usage] [API] – A toolkit for developing and comparing reinforcement learning algorithms
- LLVM – [sample usage] [API] – A collection of modular and reusable compiler and toolchain technologies
- libffi – [sample usage] [API] – A portable foreign-function interface library
- libpostal – [sample usage] [API] – For parsing/normalizing street addresses around the world
- LibRaw – [sample usage] [API] – A simple and unified interface for RAW files generated by digital photo cameras
- 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
- OpenPose – [sample usage] [API] – Real-time multi-person keypoint detection for body, face, hands, and foot estimation
- CUDA – [sample usage] [API] – Arguably the most popular parallel computing platform for GPUs
- NVIDIA Video Codec SDK – [sample usage] [API] – An API for hardware accelerated video encode and decode
- OpenCL – [sample usage] [API] – Open standard for parallel programming of heterogeneous systems
- MXNet – [sample usage] [API] – Flexible and efficient library for deep learning
- PyTorch – [sample usage] [API] – Tensors and dynamic neural networks with strong GPU acceleration
- SentencePiece – [sample usage] [API] – Unsupervised text tokenizer for neural-network-based text generation
- TensorFlow – [sample usage] [API] – Computation using data flow graphs for scalable machine learning
- TensorFlow Lite – [sample usage] [API] – An open source deep learning framework for on-device inference
- TensorRT – [sample usage] [API] – High-performance deep learning inference optimizer and runtime
- Triton Inference Server – [sample usage] [API] – An optimized cloud and edge inferencing solution
- ALE – [sample usage] [API] – The Arcade Learning Environment to develop AI agents for Atari 2600 games
- DepthAI – [sample usage] [API] – An embedded spatial AI platform built around Intel Myriad X
- ONNX – [sample usage] [API] – Open Neural Network Exchange, an open source format for AI models
- nGraph – [sample usage] [API] – An open source C++ library, compiler, and runtime for deep learning frameworks
- ONNX Runtime – [sample usage] [API] – Cross-platform, high performance scoring engine for ML models
- TVM – [sample usage] [API] – An end to end machine learning compiler framework for CPUs, GPUs and accelerators
- Bullet Physics SDK – [sample usage] [API] – Real-time collision detection and multi-physics simulation
- LiquidFun – [sample usage] [API] – 2D physics engine for games
- Qt – [sample usage] [API] – A cross-platform framework that is usually used as a graphical toolkit
- Skia – [sample usage] [API] – A complete 2D graphic library for drawing text, geometries, and images
- cpu_features – [sample usage] [API] – A cross platform C99 library to get cpu features at runtime
- ModSecurity – [sample usage] [API] – A cross platform web application firewall (WAF) engine for Apache, IIS and Nginx
- 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
Please refer to the contribute and download pages for more information about how to help out or obtain this software.
See the developer site on GitHub for more general information about the Bytedeco projects.
Latest News
Introducing JavaCV frame converters
To supplement the long-standing functionality of CanvasFrame
, FrameGrabber
, FrameRecorder
, and their implementation classes found in JavaCV, we are introducing the concept of FrameConverter
starting with version 0.11, released today. Other more minor changes have been made to all the components since version 0.10, so be sure to check out the repositories on GitHub: JavaCPP, JavaCPP Presets, JavaCV, ProCamCalib, and ProCamTracker.
A FrameConverter
, in short, allows the user to share easily the same audio samples or video image data among different APIs, but without coupling their applications to all of those APIs. For example, JavaCV currently ships with AndroidFrameConverter
, Java2DFrameConverter
, and OpenCVFrameConverter
to let users represent image data as either android.graphics.Bitmap
, java.awt.image.BufferedImage
, IplImage
, or Mat
. The plain old data class adopted by JavaCV is Frame
, which does not itself depend on either Android, FFmpeg, Java 2D, or OpenCV. A user could for example grab and record frames using FFmpegFrameGrabber
and FFmpegFrameRecorder
, without requiring anything more than FFmpeg. We could further display those frames with CanvasFrame
, creating a dependency on Java 2D, or alternatively, on Android, if we transfer the frames to video memory with AndroidFrameConverter
. To further process the data, one might start using OpenCVFrameConverter
, automatically creating a dependency on OpenCV that was not present until that point. We intentionally designed the API to be as easy to use as possible, but at the same time as efficient as possible, eliminating data copies whenever the underlying APIs allow. A typical usage scenario might look like this:
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("video.mp4");
AndroidFrameConverter converterToBitmap = new AndroidFrameConverter();
OpenCVFrameConverter.ToMat converterToMat = new OpenCVFrameConverter.ToMat();
// Grab an image Frame from the video file
Frame frame = grabber.grab();
// Perform a shallow copy to represent frame as a Mat
Mat mat = converterToMat.convert(frame);
// Do some processing on mat with OpenCV
Mat processedMat = ...
// Convert processedMat back to a Frame
frame = converterToMat.convert(processedMat);
// Copy the data to a Bitmap for display or something
Bitmap bitmap = converterToBitmap.convert(frame);
It is also possible to pass a FrameConverter
in a generic way to prevent unnecessary processing of data, for example:
<I> void process(FrameConverter<I> converter, I image) {
if (someCondition) {
Frame frame = converter.convert(image);
// Process frame.image...
}
}
As a side note, to implement Java2DFrameConverter
we used code previously found inside the opencv_core
helper class. On Android, this was problematic because it would cause the log file to fill up with warnings about classes missing from the java.awt
package. Moving that code out fixed this annoyance. As a less happy consequence, to recover the functionality that was lost, existing users need to refactor their code based on a combination of Java2DFrameConverter
and OpenCVFrameConverter
. To limit these kinds of breaking changes, the features are still very limited, but in a way, this is intentional. It allows users to focus on what is missing, rather than on figuring out how to use everything. We are aware of no precedent to a framework like JavaCV that has attempted to bridge the gap between multimedia and computer vision across platforms.
In any case, we hope that overall you find this “frame processing” technique practical for your own applications, and as usual, if you have any questions, problems, or would like to contribute, but are unsure how to proceed, please feel free to share your concerns on the mailing list or via “issues” on GitHub. Enjoy and thank you for your continued interest!