or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

computer-vision.mdgpu-computing.mdindex.mdmachine-learning.mdmultimedia.mdscientific-computing.mdtext-processing.md
tile.json

tessl/maven-org-bytedeco--javacpp-presets-platform

Cross-platform Java bindings for 60+ native C/C++ libraries including OpenCV, FFmpeg, PyTorch, TensorFlow, and scientific computing libraries

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.bytedeco/javacpp-presets-platform@1.5.x

To install, run

npx @tessl/cli install tessl/maven-org-bytedeco--javacpp-presets-platform@1.5.0

index.mddocs/

JavaCPP Presets Platform

JavaCPP Presets Platform is a comprehensive meta-package that provides Java bindings for 60+ native C/C++ libraries. This platform bundle enables cross-platform access to computer vision, machine learning, scientific computing, multimedia processing, and system libraries through JavaCPP's automatic native library loading.

Package Information

  • Package Name: javacpp-presets-platform
  • Package Type: maven
  • Language: Java
  • Installation: mvn dependency:get -Dartifact=org.bytedeco:javacpp-presets-platform:1.5.11

Maven dependency:

<dependency>
  <groupId>org.bytedeco</groupId>
  <artifactId>javacpp-presets-platform</artifactId>
  <version>1.5.11</version>
</dependency>

Gradle dependency:

implementation 'org.bytedeco:javacpp-presets-platform:1.5.11'

Core Imports

import org.bytedeco.javacpp.Loader;
import org.bytedeco.opencv.opencv_core.*;
import org.bytedeco.ffmpeg.avcodec.*;
import org.bytedeco.pytorch.torch.*;

Basic Usage

import org.bytedeco.javacpp.Loader;
import org.bytedeco.opencv.opencv_core.*;
import org.bytedeco.opencv.opencv_imgcodecs.*;
import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_imgcodecs.*;

public class Example {
    static {
        // Load native libraries
        Loader.load(opencv_core.class);
        Loader.load(opencv_imgcodecs.class);
    }
    
    public static void main(String[] args) {
        // Load and process an image with OpenCV
        Mat image = imread("input.jpg");
        Mat gray = new Mat();
        cvtColor(image, gray, COLOR_BGR2GRAY);
        imwrite("output.jpg", gray);
        
        // Clean up native memory
        image.deallocate();
        gray.deallocate();
    }
}

Architecture

The JavaCPP Presets Platform is built around several key components:

  • Platform Bundle: Meta-package that includes all available presets for cross-platform deployment
  • Native Library Loading: Automatic loading of platform-specific native libraries via Loader.load()
  • Memory Management: JavaCPP's Pointer classes provide automatic and manual memory management
  • Cross-Platform Support: Binaries included for Linux, macOS, Windows, Android, and iOS
  • Module Organization: Each native library has its own org.bytedeco.<library> package namespace

Capabilities

Computer Vision & Image Processing

Core computer vision capabilities through OpenCV bindings, providing comprehensive image processing, feature detection, object recognition, and camera interfaces.

// OpenCV Mat class for image data
public class Mat extends Pointer {
    public Mat();
    public Mat(int rows, int cols, int type);
    public Mat(Size size, int type);
    public native int rows();
    public native int cols();
    public native int type();
}

// Global functions for image I/O
public static native Mat imread(String filename);
public static native Mat imread(String filename, int flags);
public static native boolean imwrite(String filename, Mat img);

Computer Vision

Multimedia Processing

Video and audio processing through FFmpeg bindings, enabling encoding, decoding, streaming, and format conversion operations.

// Core FFmpeg context structures
public class AVFormatContext extends Pointer {
    public static native AVFormatContext avformat_alloc_context();
    public native int avformat_open_input(AVFormatContext ps, String url, AVInputFormat fmt, AVDictionary options);
}

public class AVCodecContext extends Pointer {
    public static native AVCodecContext avcodec_alloc_context3(AVCodec codec);
    public native int avcodec_open2(AVCodec codec, AVDictionary options);
}

Multimedia Processing

Machine Learning & AI

Machine learning capabilities through PyTorch, TensorFlow, ONNX, and other ML framework bindings for training and inference.

// PyTorch Tensor operations
public class Tensor extends Pointer {
    public static native Tensor zeros(long[] sizes);
    public static native Tensor ones(long[] sizes);
    public native Tensor add(Tensor other);
    public native Tensor mm(Tensor mat2);
}

// TensorFlow Lite Interpreter
public class Interpreter extends Pointer {
    public Interpreter(ByteBuffer modelBuffer);
    public native void run(Object[] inputs, Object[] outputs);
}

Machine Learning

Scientific Computing

Mathematical and scientific computing through OpenBLAS, Intel MKL, NumPy, SciPy, and specialized libraries.

// OpenBLAS linear algebra operations
public static native void cblas_dgemm(int Order, int TransA, int TransB,
    int M, int N, int K, double alpha, DoublePointer A, int lda,
    DoublePointer B, int ldb, double beta, DoublePointer C, int ldc);

// FFTW transform operations  
public static native fftw_plan fftw_plan_dft_1d(int n, DoublePointer in,
    DoublePointer out, int sign, int flags);

Scientific Computing

GPU Computing

GPU acceleration through CUDA, OpenCL, and associated libraries for high-performance parallel computing.

// CUDA device management
public static native int cudaSetDevice(int device);
public static native int cudaGetDeviceCount(IntPointer count);
public static native int cudaMalloc(PointerPointer devPtr, long size);

// OpenCL context and queue management
public static native cl_context clCreateContext(cl_context_properties properties,
    int num_devices, cl_device_id devices, CreateContextCallbackFunction pfn_notify,
    Pointer user_data, IntPointer errcode_ret);

GPU Computing

Text Processing & OCR

Text recognition and natural language processing through Tesseract, Leptonica, and SentencePiece.

// Tesseract OCR API
public class TessBaseAPI extends Pointer {
    public TessBaseAPI();
    public native boolean Init(String datapath, String language);
    public native void SetImage(BytePointer imagedata, int width, int height,
        int bytes_per_pixel, int bytes_per_line);
    public native String GetUTF8Text();
}

Text Processing

Common Usage Patterns

Memory Management

JavaCPP provides automatic memory management through PointerScope and manual control via deallocate():

// Automatic cleanup with PointerScope
try (PointerScope scope = new PointerScope()) {
    Mat image = new Mat(480, 640, CV_8UC3);
    // image automatically deallocated when scope closes
}

// Manual cleanup
Mat image = new Mat(480, 640, CV_8UC3);
// ... use image
image.deallocate();

Library Loading

Each module requires explicit loading of its native libraries:

static {
    Loader.load(opencv_core.class);
    Loader.load(opencv_imgproc.class);
    Loader.load(ffmpeg.class);
}

Cross-Platform Deployment

Platform-specific artifacts are automatically selected based on the runtime environment:

  • linux-x86_64, linux-arm64, macosx-x86_64, macosx-arm64, windows-x86_64
  • android-arm, android-arm64, android-x86, android-x86_64
  • ios-arm64, ios-x86_64

Types

// Base pointer class for all native objects
public abstract class Pointer implements AutoCloseable {
    public native void deallocate();
    public native boolean isNull();
    public native long address();
}

// Automatic resource management
public class PointerScope implements AutoCloseable {
    public PointerScope();
    public void attach(Pointer p);
    public void detach(Pointer p);
    public void close();
}

// Common native data types
public class BytePointer extends Pointer {
    public BytePointer(String s);
    public BytePointer(byte[] array);
    public native String getString();
}

public class IntPointer extends Pointer {
    public IntPointer(int[] array);
    public native int get(long i);
    public native IntPointer put(long i, int value);
}

public class DoublePointer extends Pointer {
    public DoublePointer(double[] array);
    public native double get(long i);
    public native DoublePointer put(long i, double value);
}

// OpenCV basic types used in API signatures
public class Size extends Pointer {
    public Size();
    public Size(double width, double height);
    public native double width();
    public native double height();
}

// Common OpenCV constants
public static final int CV_8UC1 = 0;    // 8-bit unsigned single channel
public static final int CV_8UC3 = 16;   // 8-bit unsigned 3 channels (BGR)
public static final int COLOR_BGR2GRAY = 6;  // BGR to grayscale conversion