πΈ The high-performance native camera module for the FastJava ecosystem. Hardware-accelerated capture via MediaFoundation, WinRT, and DirectShow with SIMD color conversion.
FastCamera brings real hardware-accelerated camera capture to Java. By bypassing standard slow APIs and using direct native pipelines, it achieves ultra-low latency 1080p@60fps capture with SIMD-accelerated YUVβRGBA conversion.
import fastcamera.FastCamera;
import fastcamera.CameraDevice;
import fastimage.FastImage;
import java.nio.ByteBuffer;
import java.util.List;
public class Demo {
public static void main(String[] args) {
// 1. Enumerate available cameras across WinRT, MediaFoundation, and DirectShow
List<CameraDevice> devices = FastCamera.enumerateDevices();
if (devices.isEmpty()) {
System.out.println("No cameras detected.");
return;
}
// 2. Open primary camera
CameraDevice dev = devices.get(0);
FastCamera camera = FastCamera.open(dev.getId());
// 3. Start high-performance streaming (e.g. 1080p @ 60fps)
ByteBuffer directBuffer = camera.startStream(1920, 1080, 60);
// 4. Capture single frame directly as SIMD-accelerated FastImage
FastImage frameImage = camera.captureImage();
if (frameImage != null) {
// Apply SIMD filters with zero JVM garbage collection
FastImage processed = frameImage.resize(640, 360).grayscale();
}
// 5. Clean up native resources
camera.stopCapture();
camera.close();
}
}- Why FastCamera?
- Quick Start
- Key Features
- Real-World Use Cases
- Architecture & Pipeline
- Performance Benchmarks
- API Quick Reference
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Capturing camera and webcam video in standard Java usually involves bloated multi-megabyte wrappers, JNI overhead, or slow OpenCV/JavaCV bridges that force unnecessary memory copies:
- Slow Format Conversion: Most webcams output hardware YUV (YUY2/NV12) or MJPEG. Standard Java converts these formats on the CPU using slow scalar loops, burning 30β50% CPU just for color conversion.
- Heavy Heap Allocation: Creating new image objects or byte arrays per frame creates extreme JVM Garbage Collection pressure at 60 FPS, resulting in dropped frames and unpredictable stutter.
- Fragile Backend Support: Many Java camera libraries depend on outdated 32-bit DirectShow filters or fail on modern Windows 10/11 WinRT camera permissions.
FastCamera eliminates these pain points with a clean, native-first architecture:
- Triple Native Backend: Automatically selects between WinRT, MediaFoundation, and DirectShow for maximum device compatibility.
- Zero-Copy Streaming: Direct native frame mapping exposes raw video buffers to Java via
DirectByteBufferwith 0 GC overhead. - FastImage Ecosystem Bridge: Seamlessly wrap or capture video frames directly into off-heap
FastImageinstances for SIMD filtering.
- π₯ Triple Native Engine β Automatic hardware-accelerated pipeline selection (WinRT, MediaFoundation, DirectShow).
- βοΈ SIMD Color Conversion β High-speed YUVβRGBA conversion leveraging AVX2 and SSE4.2 vector instructions.
- π₯ Zero-Copy Streaming β Direct access to native video memory via
DirectByteBufferwith 0 heap bytes allocated. - πΌοΈ FastImage Ecosystem Bridge β Instant zero-copy interoperability with
FastImagefor SIMD resize, blur, and vision filtering. - β±οΈ Ultra-Low Latency β Async native capture callbacks delivering stable 1080p @ 60 FPS.
- π FastCore Integration β Unified native DLL loading and extraction without manual environment setup.
- ποΈ Computer Vision & AI Tracking: Stream raw camera frames directly to YOLO, OpenCV, or TensorRT with zero latency.
- ποΈ Live Streaming & Virtual Camera Overlays: Process and filter webcam video with real-time Kawase background blur via
FastImage. - π Industrial Inspection & OCR: High-framerate capture for barcode scanning, text extraction, and optical inspection.
- π€ Autonomous Robotics & Drones: Low-overhead visual feedback loop running on resource-constrained JVM runtimes.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Physical Camera Hardware / UVC Webcam β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β Native OS Subsystems (WinRT / MF / DirectShow)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Hardware YUV Stream (YUY2 / NV12) β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β Hand-Tuned AVX2 / SSE4.2 SIMD Kernels
β (Hardware-Accelerated Color Conversion)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Native Pre-Allocated Frame Pool β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β Zero-Copy Direct JNI
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Java Application (Direct ByteBuffer / FastImage) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Measured on official JMH Benchmark (Throughput in ops/ms):
Benchmark Mode Cnt Score Error Units
Benchmark.benchmarkEnumerateDevices thrpt 3 0.802 ops/ms
Note
Environment & Setup: Measured on an Intel Core i7 with Windows 11. Native MediaFoundation device probing and capability negotiation executes in ~1.2 ms with complete metadata extraction and zero JVM heap pollution.
| Method | Description | Docs |
|---|---|---|
enumerateDevices() |
Queries all connected camera devices. | Reference π |
open(deviceId) |
Opens target camera device by native ID. | Reference π |
startStream(w, h, fps) |
Zero-Copy: Maps native frame memory to DirectByteBuffer. |
Reference π |
captureImage() |
FastImage Bridge: Captures frame to off-heap FastImage. |
Reference π |
getStreamImage() |
Zero-Copy FastImage: Wraps streaming buffer directly. | Reference π |
takePicture() |
Captures current frame as standard BufferedImage. |
Reference π |
close() |
Releases camera hardware and streams. | Reference π |
Add the JitPack repository and the dependencies to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastCamera Library -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCamera</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastImage Frame Bridge -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastImage</artifactId>
<version>0.1.2</version>
</dependency>
<!-- FastCore (Required Native Loader) -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastCamera:0.1.1'
implementation 'com.github.andrestubbe:FastImage:0.1.2'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest JARs directly to add them to your classpath:
- π¦ FastCamera-0.1.1.jar (The Core Library)
- β‘ FastImage-0.1.2.jar (The SIMD Image Engine)
- βοΈ FastCore-0.1.0.jar (The Mandatory Native Loader)
- COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
- REFERENCE.md: Full API descriptions, border configurations, and codepoint index.
- PHILOSOPHY.md: The engineering rationale for zero-allocation performance.
- ROADMAP.md: Future milestones and planned features.
| Platform | Status |
|---|---|
| Windows 10/11 | β Fully Supported |
| Linux | π Planned |
| macOS | π Planned |
MIT License See LICENSE file for details.
- FastFileIndex - Binary file indexing with mmap support
- FastFileSearch - Prefix Trie, N-Gram index, and Ranking engine
- FastFileWatch - USN Journal-based live file monitoring
- FastCore - Unified JNI loader and platform abstraction
Part of the FastJava Ecosystem β Making the JVM faster. Small package. Maximum speed. Zero bloat. ππ
