问题描述
当我使用cv2.imshow(img)时,colab给出了disabledFunctionError(https://github.com/jupyter/notebook/issues/3935),因此我使用了cv2_imshow(img)来给出此错误,如图所示(AttributeError:'nonetype'对象没有属性'剪辑”)。
解决方法
在Google Colab中使用cv2.imshow(img)返回以下输出:
DisabledFunctionError: cv2.imshow() is disabled in Colab,because it causes Jupyter sessions
to crash; see https://github.com/jupyter/notebook/issues/3935.
As a substitution,consider using
from google.colab.patches import cv2_imshow
因此,您可以简单地使用:
from google.colab.patches import cv2_imshow
import matplotlib.pyplot as plt
img = "yourImage.png"
img = cv2.imread(img) # reads image
plt.imshow(img)
,
尝试一下:
from google.colab.patches import cv2_imshow
cv2_imshow(img)