title: How to open an image from an url with opencv using requests from python
body: <p>I am trying to open a large list of images using OpenCV on python, because I need to work with them latter.</p>
  
  <p>Actually, I can achieve this goal with pillow like this:</p>
  
  <pre><code>url = r'https://i.imgur.com/DrjBucJ.png'
  response = requests.get(url, stream=True).raw
  guess = Image.open(response).resize(size)
  </code></pre>
  
  <p>I am using the library <code>requests</code> from python.</p>
  
  <p>The <code>response</code> looks like this: <code>b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\xdb\...</code></p>
  
  <p>And if I am not wrong, those are the values of the pixels from the image of the url, correct?</p>
  
  <p>My question is: how can I do the same with OpenCV?</p>
  
  <p>I have tried it like:</p>
  
  <pre><code>resp = requests.get(url)
  image = np.asarray(bytearray(resp.read()), dtype="uint8")
  image = cv2.imdecode(image, cv2.IMREAD_COLOR)
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre><code>image = np.asarray(bytearray(resp.read()), dtype="uint8")
  AttributeError: 'Response' object has no attribute 'read'
  </code></pre>
  
  <p>I got the code from this web: <a href="https://www.pyimagesearch.com/2015/03/02/convert-url-to-image-with-python-and-opencv/" rel="noreferrer">https://www.pyimagesearch.com/2015/03/02/convert-url-to-image-with-python-and-opencv/</a></p>