代码是
import numpy as np
import matplotlib.pyplot as plt
import sys
image = cv2.imread(sys.argv[1])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
plt.imshow(gray, cmap="gray")
plt.show()
edges = cv2.Canny(gray, threshold1=30, threshold2=100)
plt.imshow(edges, cmap="gray")
plt.show()
当我按照此处链接的教程中的说明输入时,它不起作用并显示上面的消息。 https://www.thepythoncode.com/article/canny-edge-detection-opencv-python 完整的消息是
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
任何帮助将不胜感激。谢谢!
答案 0 :(得分:0)
如果你使用像 ubuntu 这样的 linux 需要从终端安装 thinker
sudo apt-get install python3-tk
在 Mac 上
xcode-select --install
brew uninstall python
brew install python --with-tcl-tk