OpenCV error - cv2.cvtcolor

前端 未结 4 1717
梦谈多话
梦谈多话 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:49

    imagine you have a function called preprocessing() that preprocess your images with cv2, if you try to apply it as:

    data = np.array(list(map(preprocessing,data)))
    

    it won't work and that because np.array creates int64and you are trying to assign np.uint8 to it, what you should do instead is adding dtype parameter as follow:

    data = np.array(list(map(preprocessing,data)), dtype = np.uint8)
    

提交回复
热议问题