While trying to read a video stream form an IP camera using:
stream = cv2.VideoCapture(src)
(grabbed, frame) = stream.read()
The grabbed returns True while sometimes the frames are corrupted (probably due to high CPU load). An internal Opencv error like the following is showing on the terminal:
[h264 @ 0x25e99400] error while decoding MB 87 29, bytestream -5
Is there a way to catch this error? Please note that I tried the obvious try:except with cv2.error etc. In such case of corrupted frame it would be preferable to restart the connection to the camera.
Any cpp output/error can be retrieved from Python using wurlitzer
from wurlitzer import pipes
with pipes() as (out, err):
<any call to cpp code>
c_error = err.read()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With