我正在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