cv2_imshow return PIL object instead of display image on Colab

Viewed 54

I am facing a problem in displaying image on Colab. The code that I run is in .py file which I run on Colab, so in that file I have import cv2_imshow instead of normal cv2 and called it in a file. from google.colab.patches import cv2_imshow

When I run it, it is working with no errors but the function cv2_show is not displaying image instead it return object.

enter image description here

It return this instead <PIL.Image.Image image mode=RGB size=400x400 at 0x7F0B8C132C10>

        # Frame's Shape (400,400,3)
        print(type(frame))
        
       
        cv2_imshow(frame)

The input I pass to it is in numpy array of shape (400,400,3)

I tried another way by saving an image and use PILLOW to display it and it still give object but different type of object <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=400x400 at 0x7FF8C204D7D0>.

        # Frame's Shape (400,400,3)
        cv2.imwrite('landmark_test.jpg', frame)
        #cv2_imshow(frame)
        dpi = Image.open('landmark_test.jpg')
        display(dpi)

enter image description here

0 Answers
Related