錯誤一: ModuleNotFoundError: No module named 'imtools’
解決辦法: 找到imtools.py文件添加到項目的工程文件夾下即可。
即,添加`from PCV.tools import imtools
錯誤二: ImportError: cannot import name ‘imresize’ from ‘scipy.misc’ (F:\Anaconda\lib\site-packages\scipy\misc_init_.py)
原因: imresize功能將在1.2.0版本中,被skimage.transform.resize取代。This function is only available if Python Imaging Library (PIL) is installed.該功能只在安裝了PIL情況下使用。
解決辦法:換一種寫法,通過numpy來實現,import語句如下所示(當然,仍然需要依賴Pillow庫,可以用語句pip install pillow進行安裝)。
from PIL import Image
import numpy as np
imresize使用示例(被註釋的第一行是基於scipy庫的寫法,第二行是基於numpy的寫法):
# im = imresize(im, (h, int(w * aspect_ratio)), interp='bicubic')
im = np.array(Image.fromarray(im).resize((h, int(w * aspect_ratio))))
錯誤三: TypeError: ‘dict_items’ object does not support indexing
錯誤代碼: for pos,label in cuts.items()[:-2]:
錯誤原因: 在Python 2.X中, for pos,label in cuts.items()[:-2]: #don’t add source/sink 返回的是一個 list, 但是在Python 3.X中返回的是一個dict_keys object。
解決辦法: for pos,label in list(cuts.items())[:-2]:
錯誤四: IndexError: too many indices for array
錯誤原因: 索引錯誤:數組的索引太多
錯誤五: NameError: name ‘array’ is not defined
解決辦法: from numpy import *
添加這一行代碼即可。
錯誤六: NameError: name ‘meshgrid’ is not defined
解決辦法:from numpy import *
添加這行代碼即可。
錯誤七: NameError: name ‘figure’ is not defined
解決辦法: from pylab import *
添加這行代碼即可。
錯誤八: TypeError: numpy boolean subtract, the -
operator, is deprecated, use the bitwise_xor, the ^
operator, or the logical_xor function instead.
原因:“numpy Boolean中的‘—’已被棄用。
解決辦法: 打開對應的文件夾,修改文件參數找到:
源代碼:cscale = cmax - cmin
修改後的代碼:cscale = cmax ^ cmin
錯誤九:NameError: name ‘subplot’ is not defined
解決辦法:from pylab import *
添加該語句即可。