I want to display a picture, which is given a link VK in the window. But when she tries to convert the picture with the bytearray
function, she refuses to see the uint8
encoding.
import cv2 import bs4 import requests import numpy as np request = requests.get('https://vk.com/id1?z=photo1_456317315%2Falbum1_136592355') soup = bs4.BeautifulSoup(request.text, 'lxml') soup = soup.find('a', {'class': 'mva_item'}) pic_link = soup['href'] pic_array = np.asarray(bytearray(pic_link,'uint8'), dtype='uint8') pic = cv2.imdecode(pic_array, -1)
I took an example from here and transformed it a little.