Skip to content

Real-time GStreamer video ingestion and batched frame processing pipeline with shared memory and multi-process Mediapipe feature extraction.

License

Notifications You must be signed in to change notification settings

KarthikMgOrg/google-mediapipe-gst-python-implementation

Repository files navigation

📦 google-mediapipe-gst-python-implementation

🚀 Real-Time GStreamer Video Processing with Shared Memory and Batch Processing

google-mediapipe-gst-python-implementation is a high-performance, real-time video processing pipeline that:

  • Streams frames from a GStreamer pipeline
  • Batches frames efficiently into shared memory
  • Distributes batches across multiple processes using multiprocessing queues
  • Supports scalable, parallel feature extraction (e.g. using Mediapipe)

This project is designed for low-latency, high-throughput computer vision pipelines.


📂 Project Structure

.
├── gaze_tracker.py       # gaze tracking function
├── utils.py              # Shared utilities (e.g., batch handling, frame reshaping)
├── requirements.txt      # Python package dependencies
└── README.md             # Project documentation

⚙️ Features

  • ✅ Real-time GStreamer frame ingestion
  • ✅ Batch processing for improved memory and CPU efficiency
  • ✅ Shared memory transport (zero-copy frame passing)
  • ✅ Multi-process consumer architecture (supports parallel Mediapipe tasks)
  • ✅ Easily configurable batch size and frame resolution
  • ✅ Scalable for multi-camera or high-frame-rate pipelines

🛠️ Requirements

  • Python 3.8+
  • GStreamer 1.18+

Install Python dependencies:

pip install -r requirements.txt

Example requirements.txt:

numpy
opencv-python
matplotlib

🚀 How It Works

  1. Producer:

    • Reads frames from the GStreamer pipeline using appsink
    • Writes frames into a shared memory batch buffer
    • Signals when batches are ready via a lightweight queue
  2. Consumers:

    • Listen for batch-ready signals
    • Read batches directly from shared memory (zero-copy)
    • Process each frame independently (e.g. using Mediapipe feature extraction)

📦 Usage

Run the pipeline:

python manage.py runserver

Customize:

  • Adjust BATCH_SIZE and FRAME_SHAPE in utils.py
  • Integrate your own Mediapipe feature extraction functions in consumer.py

📸 Example Pipeline

pipeline = Gst.parse_launch('videotestsrc ! video/x-raw,format=BGR,width=1280,height=720 ! appsink name=sink')

You can easily replace this with your own GStreamer input (webcam, video file, live stream, etc.)


🔗 Future Work

  • Support for double-buffering to enable full parallel read/write cycles
  • Multi-camera ingestion
  • GPU-accelerated processing support
  • Optional Kafka or distributed queue integration

📄 License

This project is licensed under the MIT License.


🤝 Contributions

Pull requests and improvements are welcome! Please open an issue first to discuss major changes.


✨ Credits

Built by http://github.com/KarthikMgk for scalable, real-time vision pipelines.

About

Real-time GStreamer video ingestion and batched frame processing pipeline with shared memory and multi-process Mediapipe feature extraction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages