Click here to Skip to main content
15,888,590 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm a beginner to python and tried to import an image to my IDE but there is an error, I worked on the error for more than three hours but in vain could some one help me with this error, please?

What I have tried:

Python


#Created by AyaNabil on 26/9/2022

    #importing packages

        import cv2
        import numpy as np
        import matplotlib.pyplot as plt
        
        # load the Image
        
        def read_file(filename):
            img = cv2.imread(filename)
            img = cv2.cvColor(img, cv2.COLOR_BGR2RGB)
            plt.imshow(img)
            plt.show()
            return img
        
        #image path 
        filename = "C:\Users\Dell Latitude E5570\OneDrive - Alexandria University\Desktop\500x500.jpg"
        
        read_file(filename)
ilename)
Posted
Updated 26-Sep-22 4:05am
v2
Comments
CPallini 26-Sep-22 9:10am    
And...
What is the error?
Aya Nabil 2022 26-Sep-22 9:58am    
AttributeError: module 'cv2' has no attribute 'cvColor'

1 solution

Quote:
img = cv2.cvColor(img, cv2.COLOR_BGR2RGB)
Mistyping error ('t' missing): The method name is cvtColor, see Python OpenCV | cv2.cvtColor() method - GeeksforGeeks[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900