[Solved] why is my opencv error even though i am following from geeksforgeeks [duplicate]


When cv2 can’t read image then it doesn’t raise error but it returns None and later it may gives error in other lines when it tries to use this None to display image (or change color, or edit image)

You should use full path in imread()imshow needs text for widow’s title, it doesn’t have to be path to image.

image = cv2.imread("C:\\Users\\farha\\Downloads\\WALLPAPER\\beach.jpg", cv2.IMREAD_COLOR)

if image is None: 
    print("I can't read image")
else:
    cv2.imshow("My Image", image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

1

solved why is my opencv error even though i am following from geeksforgeeks [duplicate]