Optimise the anonymised livestream pipeline

Aperta
#467 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, raspberry-pi

Direzione di ricerca

Start with pyro_camera_api/services/anonymizer_rtsp.py and the existing FPSMeter logs. Measure decoder, model and encoder CPU, latency and FPS on a station, then evaluate the listed copy, box-timing, hardware codec and model-input options one at a time. Done means recording before-and-after measurements in the issue and merging useful changes while the stream stays real time with the new model.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

module: engine type: enhancement

Part of pyronear/roadmap#41 (Livestream anonymisation). Independent of the model work.

Context

The blurred livestream (pyro_camera_api/services/anonymizer_rtsp.py) works like this: one ffmpeg decodes the RTSP to raw BGR frames, a thread runs the model on the last frame (BGR to RGB, PIL, letterbox), and an encoder thread copies the last frame, paints the boxes and sends it to a second ffmpeg (x264 to SRT). It works, but it spends CPU on copies and conversions, and the new model may be heavier.

What has to be done

  • Measure on a station: CPU per thread, latency, FPS of decoder, model and encoder (FPSMeter logs exist).
  • Fewer copies: give the raw frame to the model directly (NCNN can do BGR to RGB, no PIL), paint the boxes in place, avoid frame.copy() and tobytes() on every frame.
  • Box timing: boxes are painted on the current frame, not on the frame they come from. A moving object can show for a few frames. Delay the encoder by one inference, or keep the boxes longer and make them bigger.
  • Hardware decode and encode on the Pi (h264_v4l2m2m), or use a smaller camera substream.
  • Smaller model input, or run the model one frame out of N.
  • Measure again after each change, keep what helps.

Done when

  • Before and after measurements are in this issue
  • The useful optimisations are merged and the stream stays real time with the new model
Lingua principale
Python
Stelle
20
Fork
9
Merge medio
4g 21h
PR unite (30g)
12

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pyronear/pyro-engine

Tutte le issue di pyronear/pyro-engine

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.