This project is based on Drowning-Detection and has been improved for better compatibility, performance, and deployment on Kubernetes.
- Updated Dependencies: Adjusted requirements.txt for compatibility with Python 3.12.
- Microservices Enhancement: Optimized for deployment in a Kubernetes environment.
- Improved Logging & Debugging: Enhanced logging for better observability.
- Performance Tweaks: Refactored some parts to improve efficiency.
The original project was created by @randhana(https://github.com/randhana), and you can find it here: 🔗 Drowning-Detection on GitHub(https://github.com/randhana/Drowning-Detection-)
Introducing our drowning detection system, designed to detect and alert when someone is in danger of drowning. Our system uses computer vision algorithms to analyze video feeds from multiple cameras around a pool or other bodies of water.
The system works by using a deep learning-based object detection model to identify a person in the water. The model is trained on thousands of images and videos of people in water environments, allowing it to accurately recognize a human body in a variety of positions and lighting conditions. Once a person is detected, the system uses motion analysis algorithms to track their movements and monitor their safety.
Overall, the drowning detection system provides an innovative and effective solution for ensuring the safety of people in and around swimming pools. By leveraging advanced computer vision and machine learning technologies, the system can quickly and accurately identify potential drowning incidents and alert caregivers, ultimately helping to save lives.
- Computer Vision Algorithms: Analyze video feeds from multiple cameras.
- Deep Learning Model: Trained on thousands of images to detect human bodies in various positions and lighting conditions.
- Motion Analysis: Tracks movements to assess potential danger.
By providing rapid and accurate detection, this system helps to save lives and improve pool safety.
Follow the steps below to set up the Drowning Detection system:
git clone https://github.com/randhana/Drowning-Detection-.git
git clone --branch lightweight https://github.com/randhana/Drowning-Detection-.git
git clone https://github.com/ngophong010/Microservices-DrowningDetection.git
python -m venv env
pip install -r requirements.txt
To run the Drowning Detection program, follow these steps:
-
Create a "videos" Folder:
- Inside the project directory, create a folder named
videos
.
- Inside the project directory, create a folder named
-
Add Sample Videos:
- Place video files into the
videos
folder.
- Place video files into the
-
Run the Program:
python DrownDetect.py --source video_file_name.mp4
- Quit the Program:
- Press the
q
key on your keyboard.
- Press the
Watch our demonstration video showcasing the drowning detection system in action.
For more details on YOLO object detection, visit their official website.
This project uses Python, Kafka, Kubernetes, and a microservices-based architecture. Below are the instructions for setting up and deploying related components.
A Helm chart to deploy Apache Kafka on Kubernetes.
- Kubernetes 1.19+
- Helm 3.0+
helm install my-kafka ./my-kafka-chart
- Add the Bitnami Helm repository:
helm repo add bitnami https://charts.bitnami.com/bitnami
- Install Kafka without persistence:
helm install kafka-local bitnami/kafka --set persistence.enabled=false,zookeeper.persistence.enabled=false
- Deploy a Kafka client pod:
kubectl run kafka-local-client --restart='Never' --image docker.io/bitnami/kafka:3.3.1-debian-11-r19 \
--namespace drown-detector-microservice --command -- sleep infinity
-
Retrieve Kafka Client Password:
- Run the following command to retrieve the password for the Kafka client:
kubectl get secret kafka-local-user-passwords --namespace drown-detector-microservice -o jsonpath='{.data.client-passwords}' | base64 -d
- Note the password as you will need it for authentication.
- Run the following command to retrieve the password for the Kafka client:
-
Create a
client.properties
File:- Inside your local environment, create a file named
client.properties
with the following content:security.protocol=SASL_PLAINTEXT sasl.mechanism=SCRAM-SHA-256 sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \ username="user1" \ password="<retrieved_password>";
- Replace
<retrieved_password>
with the actual password you retrieved in the previous step.
- Inside your local environment, create a file named
-
Copy the
client.properties
File to the Kafka Client Pod:
kubectl cp --namespace drown-detector-microservice ./client.properties kafka-local-client:/tmp/client.properties
- If you want to access the Kafka client:
kubectl exec --tty -i kafka-local-client --namespace drown-detector-microservice -- bash
If You want to use Helm charts: cd Helm_charts/Apache-kafka
kubectl run drown-detect-svc --rm --tty -i --image phongngolam/drown-detect-service --restart Never --namespace drown-detector-microservice
kubectl run drown-alert-svc --rm --tty -i --image phongngolam/drown-alert-service --restart Never --namespace drown-detector-microservice
- Add the Kafka UI Helm repository:
helm repo add kafka-ui https://provectus.github.io/kafka-ui
- Install Kafka UI:
helm install kafka-ui kafka-ui/kafka-ui \
--set envs.config.KAFKA_CLUSTERS_0_NAME=kafka-local \
--set envs.config.KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka-local.drown-detector-microservice.svc.cluster.local:9092
- Access the Kafka UI via port forwarding:
kubectl port-forward svc/kafka-ui 8080:8080