This project performs real-time background subtraction and background replacement using OpenCV and Python.
It detects foreground movement by comparing the current frame with a captured reference background frame and replaces the background with frames from another video source.
- Real-time foreground extraction
- Background replacement using video
- Automatic video looping
- Manual background recapture
- Keyboard controls for interaction
- Works with uploaded video files
- Python
- OpenCV
- NumPy
- A reference background frame is captured.
- Each incoming frame is compared with the reference frame.
- Differences between frames are extracted.
- Foreground is separated from the background.
- The foreground is combined with another background video frame.
Upload a video file named:
uploaded_video.h264Or change the filename in the code:
cv2.VideoCapture('your_video_name.mp4')Install dependencies:
pip install -r requirements.txtpython Augmented_Reality.py| Key | Action |
|---|---|
q |
Capture current frame as background |
p |
Prepare to capture new background |
d |
Exit the program |
.
├── Augmented_Reality.py
├── requirements.txt
├── .gitignore
├── uploaded_video.h264
└── README.md- Green screen support
- Deep learning segmentation
- Better edge refinement
- Webcam live support
- Multiple background options
- Virtual background replacement
- Motion detection experiments
- Computer vision learning projects
- Video effects and editing
Shubh Sharma