Android integration for Stereolabs ZED stereo cameras over USB, targeting Android 12+ devices. Built on top of the UVCCamera library, adapted for high-bandwidth USB 3.0 ZED cameras.
This project lets an Android device act as a USB host for ZED cameras (ZED-M, ZED 2, ZED 2i), providing:
- Raw UVC capture at up to 3840×1080 (HD1080 side-by-side stereo) at 30 fps
- YUYV and MJPEG streaming
- Hardware-accelerated H.264/H.265 video recording
- Camera control parameters (exposure, gain, white balance, gamma, etc.)
- IMU sensor reading
ZED4Android/
├── libzedcamera/ # Core library: JNI/NDK bridge to libuvc/libusb, Java camera API
├── zedCameraCommon/ # Threading, encoding, and TextureView UI helpers
├── ZEDViewer/ # Sample app demonstrating live preview and recording
├── build.sh # Build helper (setup, debug, release, NDK-only, clean)
└── build.gradle # Root Gradle configuration
Native USB camera library (produces an AAR). The C++ layer wraps:
- libuvc — UVC device control and streaming
- libusb — Low-level USB communication (Android usbfs variant)
- libjpeg-turbo 1.5.0 — JPEG decoding for MJPEG streams
Key Java classes under com.stereolabs.usb:
| Class | Purpose |
|---|---|
ZEDCamera |
Main API: resolution, format, all control parameters |
USBMonitor |
USB device enumeration and permission management |
CameraDialog |
Device picker dialog |
IFrameCallback |
Callback to receive raw frames |
Shared Android utilities built on top of libzedcamera:
AbstractZEDCameraHandler— Lifecycle and threading model for camera sessionsMediaVideoEncoder/MediaSurfaceEncoder— Hardware encoder wrappersMediaMuxerWrapper— MP4 outputZEDCameraTextureView— Hardware-accelerated preview surfaceZEDImuReader— IMU polling for ZED 2i / ZED Mini (requires v518 fw)
Sample application that opens the first detected ZED camera and shows a live preview with on-screen controls for all camera parameters, plus a record button for H.264/H.265 capture.
| Requirement | Version |
|---|---|
| Android | 12+ (API 31+) |
| NDK | 29.0.14206865 (exact) |
| Gradle | 8.0+ |
| Android Gradle Plugin | 8.7.3 |
| Java | 17 |
| Build toolchain | 35.0.0 |
| Target ABI | arm64-v8a, armeabi-v7a |
USB host mode is required on the device. The ZED camera must be connected before or after app launch — the app listens for USB_DEVICE_ATTACHED intents.
./build.sh setupThis wizard auto-detects your Android SDK and creates local.properties with sdk.dir and ndk.dir. If NDK 29.0.14206865 is not installed, it will tell you how to install it:
sdkmanager "ndk;29.0.14206865"
./build.sh # debug APK (default)
./build.sh debug # debug APK explicitly
./build.sh release # release APK (unsigned)
./build.sh ndk # native libraries only, no APK
./build.sh clean # clean all build outputsPass --jobs N to control NDK parallelism (default: 8):
./build.sh debug --jobs 4Output APKs are written to:
- Debug:
ZEDViewer/build/outputs/apk/debug/ZEDViewer-debug.apk - Release:
ZEDViewer/build/outputs/apk/release/ZEDViewer-release-unsigned.apk
adb install ZEDViewer/build/outputs/apk/debug/ZEDViewer-debug.apkThe ZEDViewer app opens in landscape with these defaults (configurable in MainActivity.java):
| Setting | Value |
|---|---|
| Resolution | 2560×720 (HD720 side-by-side) |
| Frame format | YUYV |
| Frame rate | 30 fps |
| Bandwidth factor | 1.0 (full bandwidth) |
The app requests at runtime:
CAMERARECORD_AUDIOWRITE_EXTERNAL_STORAGE
USB host access is granted via a system dialog on first camera connection.
Add the modules to your project's settings.gradle:
include ':libzedcamera', ':zedCameraCommon'
project(':libzedcamera').projectDir = new File('../ZED4Android/libzedcamera')
project(':zedCameraCommon').projectDir = new File('../ZED4Android/zedCameraCommon')Then depend on them in your app's build.gradle:
dependencies {
implementation project(':zedCameraCommon')
}Subclass AbstractZEDCameraHandler (or use ZEDCameraHandler directly) to manage the camera lifecycle, and add a ZEDCameraTextureView to your layout for preview.
Copyright 2015–2026 Stereolabs. Licensed under the Apache License 2.0.
Third-party components under their respective licenses:
- libuvc, libusb — LGPL / BSD
- libjpeg-turbo — BSD
- rapidjson — MIT
- Serenegiant common — Apache 2.0