Skip to content

Repository files navigation

FastCamera 0.1.1 [ALPHA-2026-05-17] β€” Ultra-Fast Native Camera Capture for Java

Status License: MIT Java Platform JitPack


πŸ“Έ 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.


FastFileIndex Showcase


Quick Start

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();
    }
}

Table of Contents


Why FastCamera?

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:

  1. 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.
  2. 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.
  3. 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 DirectByteBuffer with 0 GC overhead.
  • FastImage Ecosystem Bridge: Seamlessly wrap or capture video frames directly into off-heap FastImage instances for SIMD filtering.

Key Features

  • πŸŽ₯ 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 DirectByteBuffer with 0 heap bytes allocated.
  • πŸ–ΌοΈ FastImage Ecosystem Bridge β€” Instant zero-copy interoperability with FastImage for 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.

Real-World Use Cases

  • πŸ‘οΈ 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.

Architecture & Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            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)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Performance Benchmarks

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.


API Quick Reference

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 πŸ“–

Installation

Option 1: Maven (Recommended)

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>

Option 2: Gradle (via JitPack)

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'
}

Option 3: Direct Download (No Build Tool)

Download the latest JARs directly to add them to your classpath:

  1. πŸ“¦ FastCamera-0.1.1.jar (The Core Library)
  2. ⚑ FastImage-0.1.2.jar (The SIMD Image Engine)
  3. βš™οΈ FastCore-0.1.0.jar (The Mandatory Native Loader)

Documentation

  • 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 Support

Platform Status
Windows 10/11 βœ… Fully Supported
Linux πŸ”— Planned
macOS πŸ”— Planned

License

MIT License See LICENSE file for details.


Related Projects


Part of the FastJava Ecosystem β€” Making the JVM faster. Small package. Maximum speed. Zero bloat. πŸš€πŸ“‹

About

πŸŽ₯ Ultra‑fast native camera capture for Java β€” hardware‑accelerated MediaFoundation/WinRT/DirectShow pipelines with zero‑copy YUV streaming, AVX2/SSE4.2 color conversion, and real‑time 1080p@60fps performance.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages