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

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'
    
asked by anonymous 19.12.2018 / 12:13

1 answer

2

The right one is COLOR_BGR2GRAY and not 'COLOR_BRG2GRAY'.

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

Conversion types can be viewed here .

    
19.12.2018 / 13:52