Skip to content

[Bug] OpenCV imread fails on Windows with Chinese/Unicode file paths #12

@x2e23t52

Description

@x2e23t52

Title:
[Bug] OpenCV imread fails on Windows with Chinese/Unicode file paths


Describe the bug
When processing images or videos located in directories containing Chinese (or other Unicode) characters or special symbols (e.g. 空格, (), []), SafeVision fails to load the file. The processing log shows an OpenCV error:

[ WARN:0@0.411] global loadsave.cpp:275 cv::findDecoder imread_('Q:\共享文件夹\X_025_沖田凛花Rinka\课件_014\课件_164\沖田凜花Rinka NO.146 Police Rinka[47P 1V 531.7M]\1 (11).jpg'): can't open/read file: check file path/integrity
Traceback (most recent call last):
  ...
AttributeError: 'NoneType' object has no attribute 'shape'

To Reproduce
Steps to reproduce the behavior:

  1. Place an image in a directory with Chinese characters and/or special symbols, e.g.

    Q:\共享文件夹\X_025_沖田凛花Rinka\课件_014\课件_164\沖田凜花Rinka NO.146 Police Rinka[47P 1V 531.7M]\1 (11).jpg
    
  2. Load this file into SafeVision.

  3. Click Start Processing.


Expected behavior
The software should be able to handle Unicode/long paths on Windows and successfully process the file (like PIL.Image.open does). Ideally, SafeVision should automatically normalize or copy files into a safe working directory to bypass OpenCV’s imread limitations.


Screenshots / Logs

  • Screenshot of the UI and error log (attached).

  • Key error:

    AttributeError: 'NoneType' object has no attribute 'shape'
    

Environment (please complete the following information):

  • OS: Windows 10/11
  • SafeVision version: v2.0
  • Python/OpenCV backend (if relevant): OpenCV 4.x (from bundled exe)
  • Input file system: Network drive Q: (SMB) with Chinese/Unicode characters in path

Additional context

  • The issue seems to be due to OpenCV’s cv::imread not supporting non-ASCII/long paths on Windows.

  • Possible solutions:

    • Use PIL.Image.open or cv::imdecode with np.fromfile to support Unicode paths.
    • Provide an option in Settings to copy input files to a safe temp folder with ASCII names before processing.
  • Workaround: moving files into a pure-English path (e.g. C:\SV\in\) allows processing to succeed.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions