【发布时间】:2021-05-15 21:34:26
【问题描述】:
我尝试使用 open-cv 从 url 读取图像。我的代码是
url = "some url"
hdr = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding': 'none',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive'}
req = urllib.request.Request(url, None, headers=hdr)
resp = urllib.request.urlopen(req)
image = np.asarray(bytearray(resp.read()), dtype="uint8")
image1 = cv2.imread(image)
但是我收到这样的错误- 图像 = cv2.imread(图像) TypeError:无法将“numpy.ndarray”类型的对象转换为“文件名”的“str”
【问题讨论】: