OpenCV error - cv2.cvtcolor

前端 未结 4 1736
梦谈多话
梦谈多话 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 15:03

    The error occured because the datatype of numpy array returned by cv2.imread is uint8, which is different from the datatype of numpy array returned by np.full(). To make the data-type as uint8, add the dtype parameter-

    img = np.full((100,80,3), 12, dtype = np.uint8)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    

提交回复
热议问题