or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# JavaCPP Presets Platform

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: javacpp-presets-platform

7

- **Package Type**: maven

8

- **Language**: Java

9

- **Installation**: `mvn dependency:get -Dartifact=org.bytedeco:javacpp-presets-platform:1.5.11`

10

11

Maven dependency:

12

```xml

13

<dependency>

14

<groupId>org.bytedeco</groupId>

15

<artifactId>javacpp-presets-platform</artifactId>

16

<version>1.5.11</version>

17

</dependency>

18

```

19

20

Gradle dependency:

21

```groovy

22

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

23

```

24

25

## Core Imports

26

27

```java

28

import org.bytedeco.javacpp.Loader;

29

import org.bytedeco.opencv.opencv_core.*;

30

import org.bytedeco.ffmpeg.avcodec.*;

31

import org.bytedeco.pytorch.torch.*;

32

```

33

34

## Basic Usage

35

36

```java

37

import org.bytedeco.javacpp.Loader;

38

import org.bytedeco.opencv.opencv_core.*;

39

import org.bytedeco.opencv.opencv_imgcodecs.*;

40

import static org.bytedeco.opencv.global.opencv_core.*;

41

import static org.bytedeco.opencv.global.opencv_imgcodecs.*;

42

43

public class Example {

44

static {

45

// Load native libraries

46

Loader.load(opencv_core.class);

47

Loader.load(opencv_imgcodecs.class);

48

}

49

50

public static void main(String[] args) {

51

// Load and process an image with OpenCV

52

Mat image = imread("input.jpg");

53

Mat gray = new Mat();

54

cvtColor(image, gray, COLOR_BGR2GRAY);

55

imwrite("output.jpg", gray);

56

57

// Clean up native memory

58

image.deallocate();

59

gray.deallocate();

60

}

61

}

62

```

63

64

## Architecture

65

66

The JavaCPP Presets Platform is built around several key components:

67

68

- **Platform Bundle**: Meta-package that includes all available presets for cross-platform deployment

69

- **Native Library Loading**: Automatic loading of platform-specific native libraries via `Loader.load()`

70

- **Memory Management**: JavaCPP's `Pointer` classes provide automatic and manual memory management

71

- **Cross-Platform Support**: Binaries included for Linux, macOS, Windows, Android, and iOS

72

- **Module Organization**: Each native library has its own `org.bytedeco.<library>` package namespace

73

74

## Capabilities

75

76

### Computer Vision & Image Processing

77

78

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

79

80

```java { .api }

81

// OpenCV Mat class for image data

82

public class Mat extends Pointer {

83

public Mat();

84

public Mat(int rows, int cols, int type);

85

public Mat(Size size, int type);

86

public native int rows();

87

public native int cols();

88

public native int type();

89

}

90

91

// Global functions for image I/O

92

public static native Mat imread(String filename);

93

public static native Mat imread(String filename, int flags);

94

public static native boolean imwrite(String filename, Mat img);

95

```

96

97

[Computer Vision](./computer-vision.md)

98

99

### Multimedia Processing

100

101

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

102

103

```java { .api }

104

// Core FFmpeg context structures

105

public class AVFormatContext extends Pointer {

106

public static native AVFormatContext avformat_alloc_context();

107

public native int avformat_open_input(AVFormatContext ps, String url, AVInputFormat fmt, AVDictionary options);

108

}

109

110

public class AVCodecContext extends Pointer {

111

public static native AVCodecContext avcodec_alloc_context3(AVCodec codec);

112

public native int avcodec_open2(AVCodec codec, AVDictionary options);

113

}

114

```

115

116

[Multimedia Processing](./multimedia.md)

117

118

### Machine Learning & AI

119

120

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

121

122

```java { .api }

123

// PyTorch Tensor operations

124

public class Tensor extends Pointer {

125

public static native Tensor zeros(long[] sizes);

126

public static native Tensor ones(long[] sizes);

127

public native Tensor add(Tensor other);

128

public native Tensor mm(Tensor mat2);

129

}

130

131

// TensorFlow Lite Interpreter

132

public class Interpreter extends Pointer {

133

public Interpreter(ByteBuffer modelBuffer);

134

public native void run(Object[] inputs, Object[] outputs);

135

}

136

```

137

138

[Machine Learning](./machine-learning.md)

139

140

### Scientific Computing

141

142

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

143

144

```java { .api }

145

// OpenBLAS linear algebra operations

146

public static native void cblas_dgemm(int Order, int TransA, int TransB,

147

int M, int N, int K, double alpha, DoublePointer A, int lda,

148

DoublePointer B, int ldb, double beta, DoublePointer C, int ldc);

149

150

// FFTW transform operations

151

public static native fftw_plan fftw_plan_dft_1d(int n, DoublePointer in,

152

DoublePointer out, int sign, int flags);

153

```

154

155

[Scientific Computing](./scientific-computing.md)

156

157

### GPU Computing

158

159

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

160

161

```java { .api }

162

// CUDA device management

163

public static native int cudaSetDevice(int device);

164

public static native int cudaGetDeviceCount(IntPointer count);

165

public static native int cudaMalloc(PointerPointer devPtr, long size);

166

167

// OpenCL context and queue management

168

public static native cl_context clCreateContext(cl_context_properties properties,

169

int num_devices, cl_device_id devices, CreateContextCallbackFunction pfn_notify,

170

Pointer user_data, IntPointer errcode_ret);

171

```

172

173

[GPU Computing](./gpu-computing.md)

174

175

### Text Processing & OCR

176

177

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

178

179

```java { .api }

180

// Tesseract OCR API

181

public class TessBaseAPI extends Pointer {

182

public TessBaseAPI();

183

public native boolean Init(String datapath, String language);

184

public native void SetImage(BytePointer imagedata, int width, int height,

185

int bytes_per_pixel, int bytes_per_line);

186

public native String GetUTF8Text();

187

}

188

```

189

190

[Text Processing](./text-processing.md)

191

192

## Common Usage Patterns

193

194

### Memory Management

195

196

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

197

198

```java

199

// Automatic cleanup with PointerScope

200

try (PointerScope scope = new PointerScope()) {

201

Mat image = new Mat(480, 640, CV_8UC3);

202

// image automatically deallocated when scope closes

203

}

204

205

// Manual cleanup

206

Mat image = new Mat(480, 640, CV_8UC3);

207

// ... use image

208

image.deallocate();

209

```

210

211

### Library Loading

212

213

Each module requires explicit loading of its native libraries:

214

215

```java

216

static {

217

Loader.load(opencv_core.class);

218

Loader.load(opencv_imgproc.class);

219

Loader.load(ffmpeg.class);

220

}

221

```

222

223

### Cross-Platform Deployment

224

225

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

226

- `linux-x86_64`, `linux-arm64`, `macosx-x86_64`, `macosx-arm64`, `windows-x86_64`

227

- `android-arm`, `android-arm64`, `android-x86`, `android-x86_64`

228

- `ios-arm64`, `ios-x86_64`

229

230

## Types

231

232

```java { .api }

233

// Base pointer class for all native objects

234

public abstract class Pointer implements AutoCloseable {

235

public native void deallocate();

236

public native boolean isNull();

237

public native long address();

238

}

239

240

// Automatic resource management

241

public class PointerScope implements AutoCloseable {

242

public PointerScope();

243

public void attach(Pointer p);

244

public void detach(Pointer p);

245

public void close();

246

}

247

248

// Common native data types

249

public class BytePointer extends Pointer {

250

public BytePointer(String s);

251

public BytePointer(byte[] array);

252

public native String getString();

253

}

254

255

public class IntPointer extends Pointer {

256

public IntPointer(int[] array);

257

public native int get(long i);

258

public native IntPointer put(long i, int value);

259

}

260

261

public class DoublePointer extends Pointer {

262

public DoublePointer(double[] array);

263

public native double get(long i);

264

public native DoublePointer put(long i, double value);

265

}

266

267

// OpenCV basic types used in API signatures

268

public class Size extends Pointer {

269

public Size();

270

public Size(double width, double height);

271

public native double width();

272

public native double height();

273

}

274

275

// Common OpenCV constants

276

public static final int CV_8UC1 = 0; // 8-bit unsigned single channel

277

public static final int CV_8UC3 = 16; // 8-bit unsigned 3 channels (BGR)

278

public static final int COLOR_BGR2GRAY = 6; // BGR to grayscale conversion

279

```