This project is a Flask-based web application that processes uploaded video files to detect and calculate respiration rates. The application uses OpenCV for video processing and dlib for face detection.
- Upload video files for processing
- Detect faces in the video
- Calculate respiration rates based on detected facial movements
- Display results including frames per second (FPS), total number of frames, respiration times, time length, and respiration rate (RR)
- Python 3.x
- Flask
- OpenCV
- dlib
- scipy
-
Clone the repository:
git clone https://github.com/yourusername/video-respiration-rate-detector.git cd video-respiration-rate-detector -
Install the required packages:
pip install -r requirements.txt
-
Download and install dlib:
# On Ubuntu or Debian sudo apt-get install -y cmake build-essential libgl1-mesa-glx # Install dlib using pip pip install dlib
-
Run the Flask application:
python app.py
-
Open your web browser and go to
http://0.0.0.0:5000. -
Upload a video file and wait for the processing to complete.
-
The results will be displayed on the web page.
You can also run this application using Docker. Follow the steps below:
-
Build the Docker image:
docker build -t video-respiration-rate-detector . -
Run the Docker container:
docker run -p 5000:5000 video-respiration-rate-detector
-
Open your web browser and go to
http://0.0.0.0:5000.
You can deploy this application on Azure Container Instances for a scalable and managed environment. Follow these steps:
-
Ensure you have the Azure CLI installed and are logged in:
az login
-
Create a resource group if you don't have one:
az group create --name myResourceGroup --location eastus
-
Create a container instance:
az container create --resource-group myResourceGroup --name videoRespirationRate --image yourdockerhubusername/video-respiration-rate-detector:latest --ports 5000 --dns-name-label video-respiration-rate --environment-variables 'FLASK_ENV'='production'
-
Find the FQDN of your container instance:
az container show --resource-group myResourceGroup --name videoRespirationRate --query ipAddress.fqdn
-
Open your web browser and navigate to the FQDN retrieved from the previous step.
app.py: The main Flask application filetemplates/index.html: The HTML file for the web interfacerequirements.txt: The Python dependencies required for the projectDockerfile: The Dockerfile for containerizing the application
GET /: The main page with the video upload formPOST /process_video: Endpoint to handle the video file upload and process the video
while Uploading
The results
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
For any questions or inquiries, please contact [email protected].

