while using this code to open a png in memory , libpng give me this warning/error:
cv2.imread("477px-PNG_Test-Wrong-Width.0_Fixed.png")
libpng error: bad adaptive filter value
This is exactly what i want because i need to retrieve informations about corrupted png in order to fix them.
But iv found myself unable to put this warning/error inside a var because as iv understood libpng use stderr to print those warnings .
So i tried many solutions to redirect stderr/stdout to a variable like this one for python >= 3.5:
import io , cv2
from contextlib import redirect_stderr
with io.StringIO() as buf, redirect_stderr(buf):
cv2.imread("477px-PNG_Test-Wrong-Width.0_Fixed.png")
output = buf.getvalue()
But it does not work..It seems that this message is print from another level of stream than python .
Can anyone please help me ?