Ask Your Question

xiejunyi1991's profile - activity

2016-11-26 07:44:43 -0500 commented answer The imread of python opencv 3.1 can't work with chinese pathdir?

I'm sure opencv 2.4 work well in 2nd examp with python 2.7
(f=ur"D:\OneDrive\火山渣颗粒原始数据\火山渣_处理.bmp".encode('gbk')).

I found when I use the command f=r"D:\OneDrive\火山渣颗粒原始数据\火山渣_处理.bmp".encode('gbk')
on python 2.7, the returned f is
b'D:\\OneDrive\\\xbb\xf0\xc9\xbd\xd4\xfc\xbf\xc5\xc1\xa3\xd4\xad\xca\xbc\xca\xfd\xbe\xdd\\\xbb\xf0\xc9\xbd\xd4\xfc_\xb4\xa6\xc0\xed.bmp'

while the return on python 3.5 is
'D:\\OneDrive\\\xbb\xf0\xc9\xbd\xd4\xfc\xbf\xc5\xc1\xa3\xd4\xad\xca\xbc\xca\xfd\xbe\xdd\\\xbb\xf0\xc9\xbd\xd4\xfc_\xb4\xa6\xc0\xed.bmp'.
Maybe the difference raise the problem.

2016-11-26 01:43:56 -0500 asked a question 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?