An interactive application that segments a person from an image, inserts them into a stereoscopic background, and creates an anaglyph 3D image. The project allows dynamic depth adjustment to position the person closer or farther in the scene.
- Person Segmentation: Automatically detects and isolates a person in an image using a pre-trained deep learning model.
- Stereoscopic Integration: Inserts the segmented person into left and right stereoscopic images.
- Anaglyph 3D Images: Combines left and right images into an anaglyph viewable with red-cyan glasses.
- Dynamic Depth Adjustment: Adjust the perceived depth of the inserted person with a slider.
- Interactive Gradio App: User-friendly interface for uploading images and generating results.
- Python 3.9 or later
- pip (Python package manager)
- Git
-
Clone the repository:
git clone <repository-url> cd project
-
Install dependencies:
pip install -r requirements.txt
-
Ensure the following directories exist:
mkdir assets output
-
Add input images to the
assets/
directory:- A person image (e.g.,
person.jpg
). - A side-by-side stereoscopic image (e.g.,
stereo.jpg
).
- A person image (e.g.,
-
Launch the app:
python src/main.py
-
Open the provided URL in a browser.
-
Upload your images:
- Person Image: Upload the image to segment.
- Stereoscopic Image: Upload the side-by-side stereoscopic image.
-
Adjust the depth level using the slider to generate a 3D anaglyph.
-
Run the segmentation script:
python src/segmentation/segment_person.py
-
This generates the segmented image with a transparent background in the
output/
directory:output/person_segmented.png
-
Run the insertion script:
python src/stereoscopic/insert_person.py
-
This generates modified left and right stereoscopic images:
output/left_with_person.png
output/right_with_person.png
-
Run the anaglyph creation script:
python src/anaglyph/create_anaglyph.py
-
This creates anaglyph images for different depths:
output/anaglyph_close.png
output/anaglyph_medium.png
output/anaglyph_far.png
- Segmented Person:
output/person_segmented.png
(Transparent image of the detected person)
- Stereoscopic Pairs:
output/left_with_person.png
output/right_with_person.png
- Anaglyph Images:
output/anaglyph_close.png
output/anaglyph_medium.png
output/anaglyph_far.png
The resulting anaglyph images can be viewed with red-cyan 3D glasses to see the depth effect.
- Support for multiple objects with independent depth adjustments.
- Enhanced background blending for better integration.
- Integration with other 3D visualization techniques (e.g., VR).
- Real-time updates with WebSocket support.