filter using ffmpeg on linux with rembg
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# Photo Background Remover
|
||||
|
||||
A simple Go program that captures a photo from your webcam and removes the background.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### 1. Install ffmpeg
|
||||
```bash
|
||||
# Ubuntu/Debian
|
||||
sudo apt install ffmpeg
|
||||
|
||||
# macOS
|
||||
brew install ffmpeg
|
||||
```
|
||||
|
||||
### 2. Install Docker
|
||||
```bash
|
||||
# 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
|
||||
|
||||
1. Build and run the program:
|
||||
```bash
|
||||
go run main.go
|
||||
```
|
||||
|
||||
2. 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 photo
|
||||
- `output/photo_TIMESTAMP_nobg.png` - Photo with background removed
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **Webcam not found**: Make sure `/dev/video0` exists (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 `video` group: `sudo usermod -a -G video $USER`
|
||||
Reference in New Issue
Block a user