我正在Python 2.7.12中使用OpenCV Canny Edge Detection。在導入matplotlib我遇到以下錯誤:UnicodeDecodeError while Image Processing in Python
> **File "C:\Python27\lib\site-packages\matplotlib\font_manager.py", line 398, in ttfFontProperty
sfnt4 = sfnt4.decode('ascii').lower()
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 0: ordinal not in range(128)**
我已經獵殺了答案,但似乎並沒有與圖片的時候找到一個解決方案。這裏是我的代碼:
import numpy as np
import cv2
from matplotlib import pyplot as plt
import sys
#read image from file specified
img = cv2.imread('test.tif', cv2.IMREAD_COLOR);
#define display window name
windowname = "Image Segmentation";
#check if image has loaded
if not img is None:
edges = cv2.Canny(img,100,200)
plt.subplot(121),plt.imshow(img,cmap = 'gray')
plt.title('Original Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(edges,cmap = 'gray')
plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
plt.show()
#start the event loop - essential
#cv2.waitKey() is a keyboard binding function (argument is time in ms).
#if you press any key in that time, the program continues.
#if 0 is passed, it waits indefinitely for a key stroke
key = cv2.waitKey(0);
#It can also be set to detect specific key strokes by recording which key is pressed
if (key == ord('x')):
cv2.destroyAllWindows();
else:
print ("No image file successfully loaded");**
Traceback的其餘部分在哪裏? – furas
回溯時間過長,超過了字符數限制!無法發佈 – singhuist