I am writing a human detection live streaming with Django + YOLOv5.
Firstly I import the video source form rtsp, then detect with it run()
function, then yield frame by frame. To stream, I use StreamingHttpResponse
with streaming_content=run()
.
It seems to work fine, but when I reload the streaming page, maybe the run()
is called again, if I reload too much, the fps decreases then the stream stops, with an AssertionError: cannot open rtsp...
I've tried a solution, to use iframe on front-end, but every time front-end shows the stream, it calls StreamingHttpRespone
and run()
again.
Do you have any solution for it?
def video_feed(request):
return StreamingHttpResponse(streaming_content=run(), content_type='multipart/x-mixed-replace; boundary=frame')