Skip to content

Instantly share code, notes, and snippets.

@diewland
Last active March 19, 2019 07:33
Show Gist options
  • Save diewland/440dd5091ef0e862d42b78ddc55cbc8a to your computer and use it in GitHub Desktop.
Save diewland/440dd5091ef0e862d42b78ddc55cbc8a to your computer and use it in GitHub Desktop.
cv2 for windows cannot read Thai/unicode image filename, this function resolved this issue.
# https://stackoverflow.com/a/43185606
def cv2_imread_win(img_filepath, np):
stream = open(img_filepath, "rb")
bytes = bytearray(stream.read())
numpyarray = np.asarray(bytes, dtype=np.uint8)
return cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment