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.

    1 answer 1

    pic_link is a link to a picture, not the picture itself:

     In [106]: print(pic_link) https://sun6-2.userapi.com/c846021/v846021265/4645a/JDTxN_vYfSM.jpg 

    OpenCV can open pictures by reference:

     ret,img = cv2.VideoCapture(pic_link).read() cv2.imshow('', img) 

    PS The ret Boolean variable will contain True if the .read() function .read() frame , otherwise False .

    • please tell me what 'ret' is in the first line? What is this variable responsible for? - PythonNewbie 5:14
    • one
      @PythonNewbie, supplemented the answer - MaxU pm