I'm attempting to use kmeans clustering to get the most common colors out of an image. It works fine with local images, but returns this error with the new functionality of pulling an image from a url. Here's the code up to the line that is throwing the error:
# import the necessary packages from sklearn.cluster import KMeans import numpy as np import urllib import argparse import utils import cv2 def getCommonColors(url): req = urllib.urlopen(url) arr = np.asarray(bytearray(req.read()), dtype=np.uint8) img = cv2.imdecode(arr,-1) image = cv2.imread(np.array_str(img)) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
Any help would be greatly appreciated!