dactylroot/rtsp

cvstream: RTSPVideoFeed.read() should not call _stream.release()

Closed this issue · 2 comments

https://github.com/statueofmike/rtsp/blob/f9ddb7be9612e150e89105c821d23c0d1669ef17/rtsp/cvstream.py#L150

this code is supposed to work for reading multiple frames from one source. why would you release the stream there? that closes the stream and prevents reading any more frames.

someone just showed up in an OpenCV support context and pointed this out.

I agree. I updated to avoid this.

Primary usage is to try to grab the most recent frame for asynchronous work. Unfortunately, opencv-python doesn't seem to support buffer management (that answer is incorrect, you can't set the buffer size). As a workaround, and to avoid adding additional threads or inline trying to empty the buffer before every read, I closed the connection instead.

Let me know if you have an idea to limit that CV buffer

if you read slower than data is generated, that's a problem that should be addressed properly.

proper solution is to either run a thread that continuously receives and keeps the most recent frame around, or to use a library that's made for this (ffmpeg, gstreamer, directshow...). OpenCV is a library for computer vision, not a media API.

OpenCV seems open to having its videoio module improved. they (Intel) won't spend time on that themselves because they focus their efforts on the actual purpose of OpenCV.