A Flutter plugin for accessing and controlling USB cameras on Android devices. This plugin enables you to connect external USB cameras (UVC - USB Video Class) to your Flutter apps and access professional camera features.
โ
USB Camera Support - Connect and control external USB cameras (UVC compatible)
โ
Real-time Preview - Display live camera feed in your Flutter app
โ
Video Recording - Record videos in MP4 format with H.264 encoding
โ
Image Capture - Take high-quality photos
โ
Audio Support - Record audio with AAC encoding
โ
Visual Effects - Apply effects like black & white, soul, zoom
โ
Multiple Camera Types - Supports Camera1, Camera2, and UVC cameras
โ
Professional Features - Resolution control, encoding options, and more
| Platform | Support |
|---|---|
| Android | โ Yes |
| iOS | โ No |
| Web | โ No |
| Windows | โ No |
| macOS | โ No |
| Linux | โ No |
- Flutter SDK: >=3.3.0
- Dart SDK: ^3.8.1
- Android minSdkVersion: 24 (Android 7.0)
- Android compileSdkVersion: 34
- USB OTG support on your Android device
- UVC compatible USB camera
The plugin now works in ANY Flutter project! ๐
Option 1: From Git (Recommended for now)
dependencies:
usb_camera_plugin:
git:
url: https://github.com/teamtechackers/create_new_camara_plugin.gitOption 2: Local Path (for development)
dependencies:
usb_camera_plugin:
path: /path/to/camera_pluging_flutter_v1Then run:
flutter pub getChoose based on your needs:
Add plugin to any project for basic camera bridge functionality.
Get complete camera UI in YOUR project with all features:
- โ USB Camera Detection - Automatic device discovery
- โ Real-time Preview - Multiple resolution support
- โ Video Recording - H.264/MP4 format
- โ Photo Capture - High-quality images
- โ Effects - Black & White, Soul, Zoom, and more
- โ Audio Recording - AAC audio support
- โ Settings & Controls - Brightness, contrast, resolution
- โ Multi-camera Support - Switch between cameras
- โ Professional UI - Modern, intuitive interface
Works in YOUR project with simple setup!
cd /Users/apple/AndroidStudioProjects/camera_pluging_flutter_v1
./setup_in_project.sh /Users/apple/AndroidStudioProjects/test_1This copies all camera files to your project!
dependencies:
usb_camera_plugin:
path: ../camera_pluging_flutter_v1Add to android/app/build.gradle:
android {
compileSdk 34
ndkVersion "27.0.12077973"
defaultConfig {
minSdk 24
multiDexEnabled true
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
// Camera dependencies
implementation 'com.afollestad.material-dialogs:core:3.2.1'
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'
implementation 'com.github.bumptech.glide:glide:4.10.0'
implementation 'com.tencent:mmkv:1.2.12'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
}Add to android/app/src/main/AndroidManifest.xml:
<activity
android:name="com.jiangdg.demo.MainActivity"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />import 'package:usb_camera_plugin/usb_camera_plugin.dart';
ElevatedButton(
onPressed: () async {
await UsbCameraPlugin().openCamera();
// Full camera UI opens! ๐
},
child: Text('Open Camera'),
)Done! Full camera features in YOUR app! ๐
๐ Detailed guide: See HOW_TO_USE_WITH_YOUR_PROJECT.md
import 'package:usb_camera_plugin/usb_camera_plugin.dart';
// Create plugin instance
final _usbCameraPlugin = UsbCameraPlugin();
// Open camera
await _usbCameraPlugin.openCamera();Add the following permissions to your AndroidManifest.xml:
<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />import 'package:flutter/material.dart';
import 'package:usb_camera_plugin/usb_camera_plugin.dart';
class CameraScreen extends StatelessWidget {
final _usbCameraPlugin = UsbCameraPlugin();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('USB Camera'),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
try {
await _usbCameraPlugin.openCamera();
} catch (e) {
print('Error opening camera: $e');
}
},
child: Text('Open USB Camera'),
),
),
);
}
}final plugin = UsbCameraPlugin();
String? version = await plugin.getPlatformVersion();
print('Platform version: $version');Main class for interacting with USB cameras.
-
openCamera()- Opens the USB camera interfaceFuture<void> openCamera()
-
getPlatformVersion()- Returns the Android platform versionFuture<String?> getPlatformVersion()
This plugin works with UVC (USB Video Class) compatible cameras, including:
- External USB webcams
- USB endoscope cameras
- USB microscope cameras
- Industrial USB cameras
- Medical USB cameras
- Most USB cameras that follow the UVC standard
- ๐ฅ Medical Applications - Endoscope and microscope integration
- ๐ญ Industrial Inspection - Quality control and monitoring
- ๐ฌ Scientific Research - Laboratory equipment integration
- ๐น Video Production - Professional camera integration
- ๐ฎ Streaming Apps - External camera support
- ๐ Security Systems - Surveillance camera integration
- Currently supports Android only
- Requires USB OTG support on the device
- Some camera-specific features may not be available on all devices
- iOS support is not available (iOS has restrictions on USB camera access)
Check out the example directory for a complete working app that demonstrates all features.
- Ensure your device supports USB OTG
- Check that the USB camera is UVC compatible
- Verify USB permissions are granted
- Try reconnecting the camera
- Make sure all required permissions are added to AndroidManifest.xml
- Request runtime permissions for Android 6.0+
- Ensure minSdkVersion is at least 24
- Run
flutter cleanand rebuild
Contributions are welcome! Please feel free to submit a Pull Request.
This plugin uses the following open-source libraries:
- AndroidUSBCamera by jiangdg
- libUVC - USB Video Class library
- libjpeg-turbo - JPEG encoding/decoding
- libusb - USB device access
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Developed with โค๏ธ for the Flutter community.
See CHANGELOG.md for a list of changes.
If you find this plugin helpful, please give it a โญ๏ธ on GitHub!
For bugs and feature requests, please file an issue on the GitHub repository.