Repository navigation
fix(io): read and write images at non-ASCII paths on Windows - #669
Open
mh-masum6875 wants to merge 1 commit into
Open
mh-masum6875 wants to merge 1 commit into
mh-masum6875 wants to merge 1 commit into
Conversation
OpenCV opens Windows paths in the ANSI code page. Image-folder sources, MOT img1 frames and the inspect commands could not read a frame under a folder with an accented, Cyrillic or CJK name, and saving a visualization there failed or left a file with a garbled name. For these paths, read and write the file bytes with NumPy and decode or encode them with OpenCV. Other paths still go straight to cv2.imread and cv2.imwrite.
mh-masum6875
requested review from
AlexBodner,
SkalskiP and
tstanczyk95
as code owners
November 12, 2026 16:30
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the Windows non-ASCII image-path fix.
No open issues 🎉
What changed in this PR
Fixes image reads and writes at non-ASCII paths on Windows across frame loading and inspection commands. Other paths and platforms retain the existing OpenCV behavior; video input and output are unchanged.
Changes:
- Adds private image helpers that use NumPy file I/O with OpenCV decoding and encoding for affected Windows paths.
- Updates all five image-loading and saving call sites.
- Adds regression tests and an Unreleased changelog entry.
| File | Description |
|---|---|
tests/io/test_image.py |
Tests non-ASCII paths, filename preservation, missing files, and frame sources. |
src/trackers/io/video.py |
Uses the read helper for image-folder frames. |
src/trackers/io/frames.py |
Uses the read helper for MOT frame images. |
src/trackers/io/_image.py |
Adds Windows-aware image read and write helpers. |
src/trackers/cli/inspect/_common.py |
Routes inspection image loading and saving through the helpers. |
src/trackers/cli/_detections.py |
Uses the read helper when loading RGB frames. |
CHANGELOG.md |
Documents the Windows non-ASCII image-path fix. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, OpenCV opens paths in the ANSI code page, so it can't read or write an image whose path has characters outside ASCII. In trackers that breaks every place frames come from image files:
So
trackers trackon an image folder, MOT sequences and thetrackers inspectcommands all fail for a dataset stored under such a folder, which on Windows is often just the user name in the home path. A non-ASCII file name in an ASCII folder is written under a garbled name instead (café.pngcomes out ascafé.png).A small private module,
trackers/io/_image.py, now wraps the read and the write. For these paths it reads or writes the file bytes with NumPy and decodes or encodes them with OpenCV. Every other path, and every other platform, still goes straight tocv2.imreadandcv2.imwrite. The five call sites use it.Added
tests/io/test_image.py. On Windows the three frame-source cases fail with the call sites reverted and pass with the change; on Linux and macOS OpenCV already handles these paths, so they pass either way.tests/ioandtests/cli(not integration): 422 passed. Ruff check and format are clean on the touched files; I didn't run the full pre-commit suite.Not covered: video files and video output go through
cv2.VideoCapture/cv2.VideoWriter, which have the same limitation and no in-memory route.Added a changelog entry under Unreleased.