0

I'm trying to make some scraping with a players game data. The script is working just fine for common character (a-Z, etc) but give me an error on imwrite() for special character nickname:

    root = saveroot +"ocrdata/"+ playername + "-" + imgtype + ".png"
    cv2.imwrite(root, var)

when an imput on the variable player name as this enter:

甜 Player

The script return an error as this:

FileNotFoundError: [Errno 2] No such file or directory: 'C:/..../ocrdata/甜 Player-id.png'

any clue ?

Pythonista
  • 27
  • 8
  • 1
    This is for reading an image with unicode filename: https://stackoverflow.com/q/43185605/5008845 Just do the opposite (e.g. use `imencode` instead of `imdecode`) – Miki Oct 26 '21 at 14:56
  • https://jdhao.github.io/2019/09/11/opencv_unicode_image_path/#write-images-with-unicode-paths – Miki Oct 26 '21 at 15:03

1 Answers1

0

this worked ;)

import cv2
import numpy as np


im_save_path = "测试目录/small_img.jpg"

is_success, im_buf_arr = cv2.imencode(".jpg", im_resize)
im_buf_arr.tofile(im_save_path)

credits

Miki
  • 40,887
  • 13
  • 123
  • 202
Pythonista
  • 27
  • 8