OpenCV error - cv2.cvtcolor

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

    It may be easier to initialize new numpy array with initial image as source and dtype=np.uint8:

    import numpy as np    
    img = cv2.imread('path//to//image//file')    
    img = np.array(img, dtype=np.uint8)
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    

提交回复
热议问题