title: TypeError: src is not a numpy array, neither a scalar
body: <pre><code>    gray_image = cv2.cvtColor(contrast, cv2.COLOR_BGR2GRAY)
  
  TypeError: src is not a numpy array, neither a scalar
  </code></pre>
  
  <p>I am currently working to solve this, any help would be appreciated. As mentioned in the comments, the PIL image needs to be converted to CV2 accepted format, can anyone provide an explanation using the example given below? </p>
  
  <pre><code>import cv2
  import numpy as np
  from matplotlib import pyplot as plt
  from cycler import cycler
  from PIL import Image, ImageEnhance
  
  # Loads the image then enhances it
  image = Image.open('lineCapture.png')
  contrast = ImageEnhance.Contrast(image)
  
  # Reads the enhanced image and converts it to grayscale, creates new file
  gray_image = cv2.cvtColor(contrast, cv2.COLOR_BGR2GRAY) //there is a problem here
  cv2.imwrite('enhancedGrayscaleLineCapture.png', gray_image)
  
  # Adaptive Gaussian Thresholding
  th1 = cv2.adaptiveThreshold(gray_image,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
          cv2.THRESH_BINARY,11,2)
  # Otsu's thresholding
  ret2,th2 = cv2.threshold(gray_image,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
  # Otsu's thresholding after Gaussian filtering
  blur = cv2.GaussianBlur(gray_image,(5,5),0)
  ret3,th3 = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
  
  # writes enhanced and thresholded img
  cv2.imwrite('enhancedGrayscaleThresholdLineCapture.png', th2)
  </code></pre>