Skip to content

haveImageReader() doc incorrect about checking for existence of file #27431

Closed
@sfe-SparkFro

Description

@sfe-SparkFro

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 😉

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy