swapnil2230/2D_3Dvideo
0
2D to VR180 Video Converter
A CPU-friendly web application built with Streamlit that converts standard 2D MP4 videos into VR180 stereoscopic videos using depth estimation with the MiDaS model.
Features
- Easy Upload: Upload your 2D MP4 video directly through the web interface.
- Depth Estimation: Utilizes MiDaS v2.1 Small model for accurate depth map generation.
- Stereoscopic Conversion: Generates left and right eye views for VR180 format.
- CPU-Friendly: Optimized for CPU processing, no GPU required.
- Interactive UI: Built with Streamlit for a user-friendly experience.
- Download Output: Download the converted VR180 video after processing.
- Adjustable Parameters: Slider to adjust 3D eye distance for customization.
Prerequisites
Before running the application, ensure you have the following installed:
- Python 3.7 or higher
- FFmpeg (for video processing)
- Download from FFmpeg official website
- Add FFmpeg to your system PATH
Installation
- Clone or download this repository to your local machine.
- Navigate to the project directory:
cd project_2D_to_3D- Install the required Python packages:
pip install -r requirements.txtUsage
- Run the Streamlit application:
python app.py- Open your web browser and go to the provided local URL (usually
http://localhost:8501).
- Upload a 2D MP4 video using the file uploader.
- Adjust the 3D eye distance slider if desired (default: 10 pixels).
- Wait for the processing to complete. The app will:
- Extract frames from the video
- Generate depth maps using MiDaS
- Create stereoscopic frames
- Reassemble into VR180 video
- Once processing is done, preview the VR180 video and download it using the provided button.
How It Works
- Frame Extraction: Uses FFmpeg to extract individual frames from the input video.
- Depth Estimation: Applies MiDaS model to each frame to generate depth maps.
- Stereoscopic Generation: Creates left and right eye views by shifting pixels based on depth.
- Video Reassembly: Combines stereoscopic frames back into a VR180 video using FFmpeg.
Dependencies
- gradio
- torch
- torchvision
- opencv-python
- numpy
- ffmpeg-python
Project Structure
project_2D_to_3D/
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── model/ # Directory for model files (currently empty)
├── sample_videos/ # Directory for sample videos (currently empty)
├── utils/ # Directory for utility functions (currently empty)
└── README.md # This fileContributing
Feel free to submit issues, fork the repository, and create pull requests for any improvements or bug fixes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- MiDaS model by Intel ISL
- Streamlit for the web framework
- FFmpeg for video processing
