Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv2.imwrite doesn't work with foreign language names in path. #211

Closed
TysonLinger opened this issue Jun 14, 2019 · 2 comments
Closed

cv2.imwrite doesn't work with foreign language names in path. #211

TysonLinger opened this issue Jun 14, 2019 · 2 comments

Comments

@TysonLinger
Copy link

Expected behaviour

cv2.imwrite("テスト/abc.jpg",img) should save an image to the specified path.

Actual behaviour

Nothing is saved to the path and no error message is provided.

Steps to reproduce

1: Create a directory named "test"
2. Try cv2.imwrite("test/abc.jpg", img). It saves the image to the path as expected.
3. Create another directory named "テスト"
4. Try cv2.imwrite("テスト/abc.jpg", img). Nothing happens.

  • Windows 10
  • Python 3.7.3
  • opencv-python==4.1.0.25
@skvark
Copy link
Member

skvark commented Jun 15, 2019

OpenCV does not support unicode file paths. See original issue in OpenCV repository: opencv/opencv#4292

@skvark skvark closed this as completed Jun 15, 2019
@vquilon
Copy link

vquilon commented Aug 1, 2019

Encoding issues.... difficult but no impossible

if you have this string = 'テスト/abc.jpg'
You can encode as Windows encoding the characters like this->
print('テスト/abc.jpg'.encode('utf-8').decode('unicode-escape'))
And you get something like this = '���/abc.jpg'

Then if you want to read the file and get the filenames readable and usable, you can use some library to read the filenames of your path and then change the encoding->
#fname is like '���/abc.jpg'
fname.encode('iso-8859-1').decode('utf-8')) # This result of your initial string ='テスト/abc.jpg'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants