cv2.cvtColor error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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