ea0f22a2ca4344c3bb0e9219d8594209641daee4
Photo Background Remover
A simple Go program that captures a photo from your webcam and removes the background.
Prerequisites
1. Install ffmpeg
# Ubuntu/Debian
sudo apt install ffmpeg
# macOS
brew install ffmpeg
2. Install Docker
# Ubuntu/Debian
sudo apt install docker.io
# macOS
brew install --cask docker
The program uses the danielgatis/rembg Docker container for background removal. The AI model (~176MB) will be downloaded automatically on first run.
Usage
- Build and run the program:
go run main.go
- The program will:
- Capture a photo from your webcam
- Remove the background
- Save both images in the
output/directory
Output
output/photo_TIMESTAMP.jpg- Original photooutput/photo_TIMESTAMP_nobg.png- Photo with background removed
Troubleshooting
- Webcam not found: Make sure
/dev/video0exists (Linux) or adjust the device in the code - ffmpeg not found: Install ffmpeg using the commands above
- Docker not found: Install Docker using the commands above
- Docker permission denied: Add your user to the docker group:
sudo usermod -a -G docker $USER(then log out and back in) - Webcam permission denied: You may need to add your user to the
videogroup:sudo usermod -a -G video $USER
Description
Languages
Go
100%