Skip to content

arjunum/Virtual-Background-Preview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Virtual Background Demo

A real-time iOS application that uses AI-powered person segmentation to replace the camera background with a custom image. The project leverages MediaPipe Selfie Segmentation and AVFoundation to process live camera frames and generate a virtual background effect.

Features

  • Real-time camera feed processing
  • AI-powered person segmentation
  • Dynamic virtual background replacement
  • Live preview rendering
  • AVFoundation camera integration
  • Optimized frame processing for smooth performance

Tech Stack

  • Swift
  • UIKit
  • AVFoundation
  • MediaPipe
  • Core Image
  • Xcode

How It Works

  1. Captures live camera frames using AVFoundation.
  2. Uses MediaPipe Selfie Segmentation to generate a segmentation mask.
  3. Separates the foreground (person) from the background.
  4. Replaces the original background with a selected image.
  5. Renders the composited output in real time.

Architecture

Components

  • CameraManager – Handles camera setup and frame capture.
  • SegmentationProcessor – Processes frames using MediaPipe.
  • ImageCompositor – Combines foreground and replacement background.
  • ViewController – Displays the final output.

Project Structure

VirtualBackgroundDemo
├── Camera
├── Segmentation
├── Processing
├── Views
└── Assets

Installation

Clone the Repository

git clone https://github.com/arjunum/VirtualBackgroundDemo.git

Open the Project

open VirtualBackgroundDemo.xcodeproj

Requirements

  • Xcode 15+
  • iOS 15.0+
  • Swift 5+
  • MediaPipe Framework

Run

Build and run the application on a physical iPhone or supported simulator.

Challenges Solved

  • Real-time camera frame processing
  • Person segmentation using AI
  • Image compositing and masking
  • Performance optimization for smooth rendering
  • Camera orientation and frame handling

Learning Outcomes

This project provided hands-on experience with:

  • AVFoundation
  • Computer Vision Concepts
  • Real-Time Image Processing
  • MediaPipe Integration
  • UIKit Development
  • Performance Optimization
  • Camera-Based iOS Applications

Future Improvements

  • Multiple background options
  • Video recording support
  • Background blur mode
  • Improved segmentation quality
  • AR-based effects

Author

Arjun U M

About

Real-time virtual background replacement for iOS using Swift, AVFoundation, and MediaPipe Selfie Segmentation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages