pythonopencvmatplotlibgoogle-colaboratoryimshow

Image is not displaying in Google Colab while using imshow()


I am working on a project which requires functions from OpenCV to plot images. I am trying to display image using the below code in Google Colab. But nothing shows up in the output. Can anybody help me with this?

%pylab notebook
import cv2

testim = imread('butterfly.jpg')
figure()
imshow(testim)
plt.show()

Screenshot:

enter image description here

Link to my Colab Notebook


Solution

  • Google colab crashes if you try to display image using cv2.imshow() instead import from google.colab.patches import cv2_imshow and display using cv2_imshow(<image>)