opencv显示图片问题
import requests, cv2import fake_useragent as fakeua
import numpy as np
from bs4 import BeautifulSoup
from io import BytesIO
url = "https://xxxxx.com.cn"
ua = fakeua.FakeUserAgent()
headers = {
"User-Agent": ua.googlechrome
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.content.decode(response.encoding), 'lxml')
imgs = soup.select('.fl_icn_g')
for img in imgs:
url2 = img.a.img['src']
image = requests.get("https://xxxxx.com.cn/" + url2, headers=headers)
image = np.array(bytearray(image.content), dtype=np.uint8)
image = cv2.imdecode(image, cv2.IMREAD_COLOR)
cv2.namedWindow('wt', cv2.WINDOW_NORMAL)
cv2.imshow('My1919810', img)
cv2.waitkey()
break
>>>
===================== RESTART: C:\Users\ASUS\Desktop\111.py ====================
Traceback (most recent call last):
File "C:\Users\ASUS\Desktop\111.py", line 20, in <module>
cv2.namedWindow('wt', cv2.WINDOW_NORMAL)
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1255: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'
是opencv不支持win11吗,gpt说opencv的官方文档提到opencv支持windwos10 代码中使用的窗口名称和等待用户按键的时间有误,请将 cv2.imshow('My1919810', img) 改为 cv2.imshow('wt', image),并将 cv2.waitkey() 改为 cv2.waitKey(0)
页:
[1]