Skip to content

Repository files navigation

Web Camera Kit πŸ“Έ

A lightweight, mobile-optimized camera boilerplate designed for AI vision and computer vision projects. Built with React, TypeScript, and modern web APIs.

πŸš€ Live Demo

Learn More On Product Site

Live Demo

Example

✨ Key Features

πŸ“± Mobile-First Design

  • Responsive interface optimized for mobile and desktop
  • PWA capabilities with offline support
  • Dynamic viewport handling for seamless mobile experience

πŸ“· Advanced Camera Functionality

  • Photo and video capture with high-quality output
  • Real-time camera switching (front/back on mobile, device selection on desktop)
  • Live video processing with canvas-based frame manipulation
  • Robust error handling and retry mechanisms

πŸ’Ύ Smart Storage System

  • IndexedDB integration for persistent media storage
  • Automatic data recovery when app reopens
  • Gallery with thumbnail generation for videos

🎨 Modern UI/UX

  • Beautiful animations powered by GSAP
  • Glassmorphism design with backdrop blur effects
  • Adaptive layouts across all screen sizes
  • Accessibility-first approach

⚑ Performance Optimized

  • Lazy loading and efficient resource management
  • Service worker for offline functionality
  • Memory leak prevention with proper cleanup

🎯 Perfect For

  • AI Vision Projects - Ready-to-use camera input for ML models
  • Computer Vision Applications - Real-time video processing
  • Educational Tools - Clean codebase for learning
  • Prototyping - Quick setup for camera-based proof of concepts

πŸ› οΈ Tech Stack

  • Frontend: React 18 + TypeScript
  • Styling: Tailwind CSS with custom animations
  • Icons: Lucide React
  • Animations: GSAP
  • Storage: IndexedDB for media persistence
  • PWA: Service Worker + Web App Manifest
  • Build Tool: Vite with PWA plugin

πŸ“¦ Installation

# Clone the repository
git clone https://github.com/yourusername/web-camera-kit.git
cd web-camera-kit

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

πŸš€ Deployment

Netlify (Recommended)

npm run build
# Deploy the 'dist' folder to Netlify

Works with any static hosting: Vercel, GitHub Pages, AWS S3, Firebase Hosting.

πŸ”§ Configuration

Environment Variables

# Disable loading screen (optional)
VITE_APP_DISABLE_LOADING_SCREEN=false

# Disable PWA features (optional)
VITE_APP_DISABLE_PWA=false

Camera Settings

// Modify in src/components/CameraPreview.tsx
const videoConstraints = {
  width: { ideal: 1920, max: 2560 },
  height: { ideal: 1080, max: 1440 },
  frameRate: { ideal: 30, max: 60 }
};

πŸ“± Browser Compatibility

Feature Chrome Firefox Safari Edge
Photo Capture βœ… βœ… βœ… βœ…
Video Recording βœ… βœ… βœ… βœ…
Camera Switching βœ… βœ… βœ… βœ…
PWA Install βœ… βœ… βœ… βœ…

Minimum Versions: Chrome 63+, Firefox 65+, Safari 12+, Edge 79+

πŸ—οΈ Architecture

Project Structure

src/
β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ CameraPreview.tsx    # Main camera interface
β”‚   β”œβ”€β”€ MediaGallery.tsx     # Gallery with thumbnails
β”‚   └── MediaPreviewModal.tsx # Full-screen viewer
β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ useMediaCapture.ts   # Media capture logic
β”‚   └── useMobileDetection.ts # Device detection
β”œβ”€β”€ utils/               # Utility functions
β”‚   β”œβ”€β”€ indexedDb.ts         # Database operations
β”‚   └── pwa.ts              # PWA management
└── types/               # TypeScript definitions

Key Components

  • CameraPreview: Camera initialization, switching, and capture
  • MediaGallery: Media display with thumbnails and batch operations
  • MediaPreviewModal: Full-screen viewing and sharing
  • useMediaCapture: Media state management and IndexedDB persistence
  • useMobileDetection: Device type detection and responsive behavior

πŸ” Security & Privacy

  • No external data transmission - All media stays on device
  • Local storage only - IndexedDB for client-side persistence
  • HTTPS required - Enforced for camera API access

πŸ”§ Development

Available Scripts

npm run dev          # Start development server
npm run build        # Build for production  
npm run preview      # Preview production build
npm run lint         # Run ESLint

Integration Examples

AI Model Integration

const processWithAI = async (imageBlob: Blob) => {
  const formData = new FormData();
  formData.append('image', imageBlob);
  
  const response = await fetch('/api/ai-process', {
    method: 'POST',
    body: formData
  });
  
  return response.json();
};

Computer Vision

const processWithOpenCV = (canvas: HTMLCanvasElement) => {
  const src = cv.imread(canvas);
  // Your CV processing here
  cv.imshow('output', src);
  src.delete();
};

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments


Ready to build camera-powered applications? Star ⭐ this repo and start creating!

About

A lightweight, mobile-optimized camera boilerplate designed specifically for AI vision and computer vision projects.

Resources

Stars

64 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages