OpenCV error - cv2.cvtcolor

前端 未结 4 1715
梦谈多话
梦谈多话 2021-02-05 14:35

I am a newbie to openCV and I am stuck at this error with no resolution. I am trying to convert an image from BGR to grayscale format using this code-

img = cv2.         


        
4条回答
  •  盖世英雄少女心
    2021-02-05 14:59

    This is because your numpy array is not made up of the right data type. By default makes an array of type np.int64 (64 bit), however, cv2.cvtColor() requires 8 bit (np.uint8) or 16 bit (np.uint16). To correct this change your np.full() function to include the data type:

    img = np.full((100,80,3), 12, np.uint8)

提交回复
热议问题