Skip to content

imread supports Non-ASCII filename in opencv-python+Windows #18305

@liuxingbaoyu

Description

@liuxingbaoyu
System information (version)
  • OpenCV => 4.4
  • Operating System / Platform => Windows
  • Compiler => opencv-python
Detailed description

#13368 (comment)
Although in this issue the opencv team decided not to change the c++ api
But the processing method in opencv-python may be better
imread was called with the wrong encoding here
should: ANSI
real: UTF8

PyObject * bytes = PyUnicode_AsUTF8String(obj);

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsMBCSString

If PyUnicode_AsUTF8String here is replaced with PyUnicode_AsMBCSString under windows, it will be able to solve the encoding problem of reading and writing files such as opencv-python imread without other influence
Note: The getUnicodeString method may not only be used for file reading and writing, so we can add a new method and use PyUnicode_AsMBCSString

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions