This project demonstrates how to stream live camera footage from an Android device using RTSP and perform object detection on the stream using YOLO (You Only Look Once) in Python. The Android application captures the camera feed and streams it over RTSP, while the Python script processes this stream to detect objects using the YOLO model.
-
Android Application:
- Captures live camera feed.
- Streams the camera feed via RTSP.
- Uses
CameraX
for camera functionalities. - Implements
ViewModel
,LiveData
, andSnackbar
for error and success messages, following the MVVM architecture.
-
Python Script:
- Connects to the RTSP stream from the Android application.
- Uses YOLO for object detection.
- Captures a 5-second GIF from the stream.
- Displays real-time object detection with bounding boxes and labels.
-
Android:
- Android Studio
- Minimum SDK version 21
- Recommended target SDK version 34
-
Python:
- Python 3.6 or higher
- OpenCV
- Ultralytics YOLO
- PyTorch
- imageio
- Clone the repository:
git clone https://github.com/oaslananka/CamStreamAndroidToPython.git
cd CamStreamAndroidToPython/android/CameraXRTSPStreaming
-
Open the project in Android Studio:
-
Build the project:
- Android Studio will automatically download the necessary dependencies.
- Navigate to the Python project directory:
cd ../python/stream_processing
- Install the required Python packages:
pip install -r requirements.txt
- Run the Python script:
python main.pyxt
- YOLO (You Only Look Once): Real-time object detection system. YOLO GitHub
- OpenCV: Open Source Computer Vision Library. OpenCV GitHub
- PyTorch: Deep learning framework. PyTorch GitHub
- RTSP Server (pedroSG94) : Library for streaming RTSP on Android. RTSP-Server GitHub