module 'cv2.cv2' has no attribute 'COLOR_BRG2GRAY'

Asked

Viewed 468 times

1

I am resizing images from a folder and am encountering the following error: module 'cv2.cv2' has no attribute 'COLOR_BRG2GRAY' Code:

pathC = './cityscape/'
dirs = os.listdir(pathC)

#Resize para o pathC np.array

def resize():
    path = pathC
    os.path.exists(path)
    orig = cv2.imread('./cityscape/')
    for img in dirs:
        if os.path.isfile(path+img):
            img = cv2.imread(path+img)
            img2 = np.array(cv2.resize(img,(512,512)))
            gray = cv2.cvtColor(img, cv2.COLOR_BRG2GRAY)

resize()

Error:

AttributeError: module 'cv2.cv2' has no attribute 'COLOR_BRG2GRAY'

1 answer

2


The right is COLOR_BGR2GRAY and not COLOR_BRG2GRAY'.

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Conversion types can be seen here.

  • Later I noticed that I had changed the letters when writing with the prey, thank you.

  • It really happens. hehe

Browser other questions tagged

You are not signed in. Login or sign up in order to post.