Ask Your Question

Revision history [back]

The imread of python opencv 3.1 can't work with chinese pathdir?

The imread command can't read a picture with a chinese path.
import cv2 import numpy as np f=r"D:\OneDrive\火山渣颗粒原始数据\火山渣处理.bmp" img=cv2.imread(f,0)

If use img=cv2.imread(f.encode('gbk'),0), there will raise a TypeError: bad argument type for built-in operatio.

  • OS: win7 64bit
  • Opencv: 3.1
  • Python: 3.5.2

But, when I use Python 2.7 and Opencv 2.4, it work well with:
f=ur"D:\OneDrive\火山渣颗粒原始数据\火山渣_处理.bmp".encode('gbk')

How can I solve this problem?