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
The cv2.imshow() and cv.imshow() functions from the opencv-python package are incompatible with Jupyter notebook; see https://github.com/jupyter/notebook/issues/3935.
As a replacement, you can use the following function:
from google.colab.patches import cv2_imshow
For example, here we download and display a PNG image of the Colab logo:
!curl -o logo.png https://colab.research.google.com/img/colab_favicon_256px.png
import cv2
img = cv2.imread('logo.png', cv2.IMREAD_UNCHANGED)
cv2_imshow(img)
Credits: Code Snippets in Google Colab