[Python] reading an image with cv2.imread vs matplotlib.pyplot.imread [duplicate]

Discussão em 'Python' iniciado por Stack, Dezembro 9, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to read and show a photo, it works when I use plt.imshow(..) and I know for sure that the photo and the path are ok.

    when I try using cv2 it says the photo is a nonetype

    import numpy as np
    import matplotlib.pyplot as plt
    import cv2

    img=cv2.imread(r'C:\Users\shayf\OneDrive\שולחן העבודה\Work\CV Course\OneDrive_1_12-4-
    2024\images\tulips.jpg')
    plt.imshow(img[:,:,::-1])


    I know plt is for RGB and cv2 is for BGR.

    It doesn't work when I try to use cv2.imread either.

    Can someone please help?

    Thanks in advance!

    Continue reading...

Compartilhe esta Página