code: def from_pillow(pil_image):
      
      # convert PIL to OpenCV
      pil_image = pil_image.convert('RGB')
      cv2_image = np.array(pil_image)
      # Convert RGB to BGR 
      cv2_image = cv2_image[:, :, ::-1].copy()
      return cv2_image
docs: Convert from pillow image to opencv