Description
Describe the doc issue
Doc link for haveImageReader()
: https://docs.opencv.org/4.11.0/d4/da8/group__imgcodecs.html#ga65d3569d8845d1210e1aeab8c199031c
The note states It does not check for the actual existence of the file but rather the ability to read the specified file type
, which is incorrect. haveImageReader()
calls findDecoder()
, which attempts to actually open the file. If the file is not present, a warning message is printed and haveImageReader()
returns False
, even if the format truly is supported. Testing in Python on my machine (where .png
definitely is supported):
>>> havePNG = cv2.haveImageReader(".png")
[ WARN:0@537.189] global loadsave.cpp:268 cv::findDecoder imread_('.png'): can't open/read file: check file path/integrity
>>> print(havePNG)
False
Fix suggestion
Can change the note to say something like:
"The file must be present. To check for an encoder/decoder without needing a file to exist, it's best to use haveImageWriter()
. The encoders and decoders come in pairs, so the existence of an image writer implies the existence of the corresponding image reader."
And maybe do a little more fact checking with the output of ChatGPT: #25888 😉