https://github.com/Michael-A-Kuykendall/crabcamera
Professional desktop camera plugin for Tauri with WebRTC live preview, automated quality validation, and advanced hardware controls. Zero-config cross-platform solution for photography apps, surveillance systems, and automated capture workflows.
https://github.com/Michael-A-Kuykendall/crabcamera
auto-capture blur-detection camera camera-api computer-vision cross-platform desktop hardware-controls image-capture live-streaming mediafoundation photography professional-controls quality-validation real-time rust surveillance tauri video-streaming webrtc
Last synced: 8 days ago
JSON representation
Professional desktop camera plugin for Tauri with WebRTC live preview, automated quality validation, and advanced hardware controls. Zero-config cross-platform solution for photography apps, surveillance systems, and automated capture workflows.
- Host: GitHub
- URL: https://github.com/Michael-A-Kuykendall/crabcamera
- Owner: Michael-A-Kuykendall
- Created: 2025-09-07T05:47:28.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-10-24T04:05:54.000Z (about 1 month ago)
- Last Synced: 2025-10-31T21:26:35.320Z (29 days ago)
- Topics: auto-capture, blur-detection, camera, camera-api, computer-vision, cross-platform, desktop, hardware-controls, image-capture, live-streaming, mediafoundation, photography, professional-controls, quality-validation, real-time, rust, surveillance, tauri, video-streaming, webrtc
- Language: HTML
- Homepage:
- Size: 370 KB
- Stars: 29
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-tauri - CrabCamera - Professional desktop camera plugin for Tauri applications with WebRTC streaming and advanced hardware controls. (Applications / Utilities)
README
# π¦ CrabCamera: The Desktop Camera Plugin for Tauri π·
```
__________________________
< Hello fellow Rustaceans! >
--------------------------
\
\
_~^~^~_
\) / o o \ (/
'_ - _'
/ '-----' \
```
[](https://crates.io/crates/crabcamera)
[](https://opensource.org/licenses/MIT)
[](https://rustup.rs/)
[](https://github.com/sponsors/Michael-A-Kuykendall)
**π¦ CrabCamera will be free forever. π¦** No asterisks. No "free for now." No pivot to paid.
## π¦ What is CrabCamera?
π¦ CrabCamera is the **first production-ready desktop camera plugin** for Tauri applications. It provides unified camera access across Windows, macOS, and Linux with professional controls and zero-config setup. It's designed to be the **invisible infrastructure** that makes desktop camera apps just work.
| Feature | CrabCamera | Web APIs | Other Plugins |
|---------|------------|----------|---------------|
| **Desktop Native** | Windows/macOS/Linux π | Limited browser | Mobile-only |
| **Hardware Access** | Direct camera control π | Browser restricted | Basic access |
| **Professional Controls** | Auto-focus, exposure π | Limited | Basic |
| **Cross-Platform** | Unified API π | Platform dependent | Single platform |
| **Production Ready** | 63 comprehensive tests π | No guarantees | Proof-of-concept |
| **Memory Safety** | Zero unsafe code π | N/A | Manual management |
## π― Perfect for Desktop Applications π¦
- **Photography**: Photo booth apps, image editors, content creation tools
- **Security**: Surveillance systems, access control, monitoring dashboards
- **Medical**: Imaging interfaces, patient documentation, diagnostic tools
- **Industrial**: Quality control, inspection systems, documentation cameras
- **Education**: Interactive learning tools, virtual labs, presentation software
- **Communication**: Video chat apps, streaming tools, conference software
**BONUS:** Professional camera controls with platform-optimized settings for maximum image quality.
## π¦ Quick Start (30 seconds) π·
### Installation
```toml
[dependencies]
crabcamera = "0.3.0"
tauri = { version = "2.0", features = ["protocol-asset"] }
```
### Tauri Integration
```rust
// src-tauri/src/main.rs
use crabcamera;
fn main() {
tauri::Builder::default()
.plugin(crabcamera::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```
```json
// tauri.conf.json
{
"plugins": {
"crabcamera": {}
}
}
```
### Frontend Usage
```javascript
import { invoke } from '@tauri-apps/api/tauri';
// Initialize camera system
await invoke('initialize_camera_system');
// Get available cameras
const cameras = await invoke('get_available_cameras');
console.log('Available cameras:', cameras);
// Get recommended format for high quality
const format = await invoke('get_recommended_format');
// Capture a photo
const photo = await invoke('capture_single_photo', {
deviceId: cameras[0].id,
format: format
});
```
## π¦ Professional Camera Features π¦
### π§ Hardware Control π¦
- **Device Enumeration**: Automatic discovery of all connected cameras
- **Format Negotiation**: Resolution, FPS, and color format selection
- **Professional Settings**: Auto-focus, auto-exposure, white balance
- **Multi-camera Support**: Switch between multiple cameras seamlessly
- **Error Recovery**: Robust handling of device disconnection and errors
### π₯οΈ Cross-Platform Native π¦
- **Windows**: DirectShow/MediaFoundation with advanced camera controls
- **macOS**: AVFoundation with Metal acceleration support
- **Linux**: V4L2 with comprehensive device support
- **Unified API**: Same code works across all platforms
- **Professional Controls**: Focus, exposure, white balance on all platforms
### β‘ Performance & Memory π¦
- **Zero-Copy Operations**: Minimal memory allocations where possible
- **Async/Await**: Non-blocking operations throughout
- **Resource Management**: Automatic cleanup and device release
- **Memory Safety**: Built with Rust's memory safety guarantees
- **Thread Safety**: Concurrent access with proper synchronization
## π§ Available Commands π¦
### Initialization & Discovery
```rust
// Initialize the camera system
initialize_camera_system() -> Result
// Get all available cameras with capabilities
get_available_cameras() -> Result>
// Get platform-specific information
get_platform_info() -> Result
// Test camera system functionality
test_camera_system() -> Result
```
### Camera Operations
```rust
// Check if specific camera is available
check_camera_availability(device_id: String) -> Result
// Get supported formats for a camera
get_camera_formats(device_id: String) -> Result>
// Get recommended settings for quality photography
get_recommended_format() -> Result
get_optimal_settings() -> Result
```
### Capture & Streaming
```rust
// Single photo capture
capture_single_photo(device_id: String, format: CameraFormat) -> Result
// Photo sequence for burst mode
capture_photo_sequence(params: SequenceParams) -> Result>
// Real-time streaming
start_camera_preview(device_id: String) -> Result<()>
stop_camera_preview() -> Result<()>
// Save frames to disk
save_frame_to_disk(frame: CameraFrame, path: String) -> Result<()>
```
### Professional Camera Controls (NEW in v0.3.0!)
```rust
// Apply camera controls (focus, exposure, white balance, etc.)
apply_camera_controls(device_id: String, controls: CameraControls) -> Result<()>
// Get current camera control values
get_camera_controls(device_id: String) -> Result
// Test what controls are supported by camera
test_camera_capabilities(device_id: String) -> Result
// Get performance metrics
get_camera_performance(device_id: String) -> Result
```
### Permissions & Security
```rust
// Handle camera permissions properly
request_camera_permission() -> Result
check_camera_permission_status() -> Result
```
## π¦ Why CrabCamera Will Always Be Free π·
I built CrabCamera because desktop applications deserve native camera access without the limitations of web APIs or mobile-only plugins.
**This is my commitment**: CrabCamera stays MIT licensed, forever. If you want to support development, [sponsor it](https://github.com/sponsors/Michael-A-Kuykendall). If you don't, just build something incredible with it.
> π¦ CrabCamera saves developers weeks of cross-platform camera integration. If it's useful, consider sponsoring for $5/month β less than a coffee, infinitely more valuable than web API limitations. π¦
## π Performance Comparison π¦
| Metric | CrabCamera | Web APIs | Mobile Plugins |
|--------|------------|----------|----------------|
| **Desktop Support** | **Full native** | Browser dependent | None |
| **Camera Access** | **Direct hardware** | getUserMedia limited | N/A |
| **Image Quality** | **Professional controls** | Basic settings | Basic |
| **Cross-Platform** | **Windows/macOS/Linux** | Browser variation | iOS/Android only |
| **Performance** | **Native speed** | Browser overhead | N/A |
| **Reliability** | **63 tests passing** | No guarantees | Varies |
## ποΈ Technical Architecture π¦
### Hybrid Capture + Controls Architecture
```
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β nokhwa β β Platform Controlsβ β CrabCamera β
β (Capture) β β (Advanced) β β (Unified API) β
βββββββββββββββββββ€ ββββββββββββββββββββ€ βββββββββββββββββββ€
β β’ Frame capture β β β’ Focus control β β β’ Generic types β
β β’ Resolution β β β’ Exposure β β β’ Error handlingβ
β β’ Format β β β’ White balance β β β’ Cross-platformβ
β β’ Start/Stop β β β’ Brightness β β β’ Thread safety β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
```
### Platform-Specific Implementations
- **Windows**: nokhwa capture + MediaFoundation controls (NEW in v0.3.0!)
- **macOS**: AVFoundation for both capture and controls
- **Linux**: nokhwa capture + V4L2 controls
- **Unified API**: Same control interface across all platforms
### Key Technologies
- **Rust + Tokio**: Memory-safe, async performance
- **Tauri 2.0 Plugin**: Modern plugin architecture
- **Platform Backends**: MediaFoundation, AVFoundation, V4L2
- **COM Interface Management**: Thread-safe Windows controls
- **Zero unsafe code**: Memory safety guaranteed (except platform COM interfaces)
## π API Reference π¦
### Core Types
```rust
pub struct CameraDeviceInfo {
pub id: String,
pub name: String,
pub description: String,
pub is_available: bool,
pub supports_formats: Vec,
}
pub struct CameraFormat {
pub width: u32,
pub height: u32,
pub fps: f32,
pub format_type: String, // "RGB8", "JPEG", etc.
}
pub struct CameraFrame {
pub data: Vec,
pub width: u32,
pub height: u32,
pub format: String,
pub timestamp: DateTime,
}
pub struct CameraControls {
pub auto_focus: Option,
pub focus_distance: Option, // 0.0 = infinity, 1.0 = closest
pub auto_exposure: Option,
pub exposure_time: Option, // seconds
pub white_balance: Option,
pub brightness: Option, // -1.0 to 1.0
pub contrast: Option, // -1.0 to 1.0
pub saturation: Option, // -1.0 to 1.0
}
pub struct CameraCapabilities {
pub supports_auto_focus: bool,
pub supports_manual_focus: bool,
pub supports_auto_exposure: bool,
pub supports_manual_exposure: bool,
pub supports_white_balance: bool,
pub focus_range: Option<(f32, f32)>,
pub exposure_range: Option<(f32, f32)>,
}
```
### Platform Detection
```rust
pub enum Platform {
Windows,
MacOS,
Linux,
Unknown,
}
// Automatic platform detection
let platform = Platform::current();
```
## π¦ Community & Support π·
- **π Bug Reports**: [GitHub Issues](https://github.com/Michael-A-Kuykendall/crabcamera/issues)
- **π¬ Discussions**: [GitHub Discussions](https://github.com/Michael-A-Kuykendall/crabcamera/discussions)
- **π Documentation**: [docs.rs/crabcamera](https://docs.rs/crabcamera)
- **π Sponsorship**: [GitHub Sponsors](https://github.com/sponsors/Michael-A-Kuykendall)
### Sponsors
See our amazing [sponsors](SPONSORS.md) who make π¦ CrabCamera possible! π
**Sponsorship Tiers:**
- **$5/month**: Coffee tier - My eternal gratitude + sponsor badge
- **$25/month**: Developer supporter - Priority support + name in SPONSORS.md
- **$100/month**: Corporate backer - Logo on README + monthly office hours
- **$500/month**: Enterprise partner - Direct support + feature requests
**Companies**: Need invoicing? Email [michaelallenkuykendall@gmail.com](mailto:michaelallenkuykendall@gmail.com)
## π Production Usage π¦
**β
Ready for production:**
- Memory-safe Rust implementation
- 63 comprehensive tests passing
- Zero unsafe code
- Comprehensive error handling
- Async/await throughout
- Cross-platform compatibility verified
**β
Use cases in production:**
- Desktop photography applications
- Security and surveillance systems
- Medical imaging interfaces
- Industrial inspection tools
- Educational software platforms
- Communication and streaming apps
## π‘ Examples & Integration π¦
### Photo Booth Application
```javascript
// Simple photo booth with camera selection
const cameras = await invoke('get_available_cameras');
const selectedCamera = cameras[0];
const format = await invoke('get_recommended_format');
// Take photo when user clicks
document.getElementById('capture').onclick = async () => {
const photo = await invoke('capture_single_photo', {
deviceId: selectedCamera.id,
format: format
});
// Display photo in UI
displayPhoto(photo);
};
```
### Multi-Camera Security System
```javascript
// Monitor multiple cameras
const cameras = await invoke('get_available_cameras');
for (const camera of cameras) {
await invoke('start_camera_preview', { deviceId: camera.id });
// Set up streaming handlers for each camera
setupCameraStream(camera);
}
```
## π License & Philosophy π¦
MIT License - forever and always.
**Philosophy**: Desktop applications deserve native camera access. π¦ CrabCamera is camera infrastructure. π·
## π What's New in v0.3.0
### π **Major Feature: Windows MediaFoundation Camera Controls**
- **Professional Windows Controls**: Full focus, exposure, white balance, brightness, contrast, and saturation control
- **Hybrid Architecture**: nokhwa capture + MediaFoundation controls for best of both worlds
- **Thread-Safe COM**: Proper Windows COM interface management for Tauri async commands
- **Capability Detection**: Runtime testing of which controls each camera supports
- **Unified API**: Same control interface across Windows, macOS, and Linux
### π§ **Technical Improvements**
- **WindowsCamera Struct**: Combines nokhwa capture with MediaFoundation controls
- **MediaFoundationControls**: Full COM interface wrapper with resource management
- **Platform Integration**: Updated PlatformCamera enum to use Windows-specific implementation
- **Error Handling**: Graceful degradation when controls aren't supported
- **Documentation**: Comprehensive technical architecture documentation
### π **Cross-Platform Parity Achieved**
Windows users now get the same professional camera control experience as macOS and Linux users!
---
**Forever maintainer**: Michael A. Kuykendall
**Promise**: This will never become a paid product
**Mission**: Making desktop camera development effortless
*"π¦ Native performance. Cross-platform compatibility. Zero hassle. π·"*
```
π¦π¦π¦ Happy Coding! π¦π¦π¦
Made with β€οΈ and Rust
π· Capture the moment π·
```