In order to allow doods2 to recover from errors in the stream when using the websocket based stream API or MQTT mode, detect when the VideoCapture is not returning data and then re-create it in order to try to fix the stream. Since we are waiting infinitely for the VideoCapture to return data, the fact that it returned no data means it has likely encountered some sort of unrecoverable error that can only be fixed by re-creating it.
In order to allow doods2 to recover from errors in the stream when using the websocket based stream API or MQTT mode, detect when the
VideoCapture
is not returning data and then re-create it in order to try to fix the stream. Since we are waiting infinitely for theVideoCapture
to return data, the fact that it returned no data means it has likely encountered some sort of unrecoverable error that can only be fixed by re-creating it.This should fix https://github.com/snowzach/doods2/issues/74
Testing
Rebooting camera before patch where doods get stuck in an infinite loop and uses ~100% CPU
Rebooting camera after patch where doods recovers and uses normal CPU: