title: Get frame to Hikvision IP Camera in python
body: <p>I have the next Hikvision IP Camera <a href="http://www.hikvision.com/es/Products_accessries_161_i11969.html" rel="noreferrer">http://www.hikvision.com/es/Products_accessries_161_i11969.html</a> I configured it in my local network and I have connection with the browser and I can see the camera working perfectly. I have searched in different post to get frame in cameras like this, but I can't do it. Here I put the code that I used to try it and the response. 
  I want to obtain a frame and save it in my destock to processed after.                 </p>
  
  <pre><code>import cv2
  import requests
  import numpy as np
  import urllib
  import hikvision.api
  import requests
  import shutil
  
  #Donwload from: https://github.com/fbradyirl/hikvision/archive/master.zip
  
  hik_camera = hikvision.api.CreateDevice('192.168.1.64', username='admin', password=contrasenia)
  """
  INFO:hikvision.api:Initialising new hikvision camera client
  INFO:hikvision.api:motion_url: http://192.168.1.64/MotionDetection/1
  INFO:hikvision.api:ElementTree.register_namespace: http://www.hikvision.com/ver10/XMLSchema
  INFO:hikvision.api:Going to probe device to test connection
  INFO:hikvision.api:url: http://192.168.1.64/System/deviceInfo
  INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.64
  DEBUG:requests.packages.urllib3.connectionpool:"GET /System/deviceInfo HTTP/1.1" 200 696
  DEBUG:hikvision.api:response: &lt;Response [200]&gt;
  DEBUG:hikvision.api:status_code 200
  DEBUG:hikvision.api:element_to_query: .//{http://www.hikvision.com/ver10/XMLSchema}firmwareVersion result: &lt;Element '{http://www.hikvision.com/ver10/XMLSchema}firmwareVersion' at 0x7fb090b76cc8&gt;
  INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.64
  DEBUG:requests.packages.urllib3.connectionpool:"GET /MotionDetection/1 HTTP/1.1" 200 407
  DEBUG:hikvision.api:Response: &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;MotionDetection version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema"&gt;
  &lt;id&gt;1&lt;/id&gt;
  &lt;enabled&gt;false&lt;/enabled&gt;
  &lt;regionType&gt;grid&lt;/regionType&gt;
  &lt;Grid&gt;
  &lt;rowGranularity&gt;18&lt;/rowGranularity&gt;
  &lt;columnGranularity&gt;22&lt;/columnGranularity&gt;
  &lt;/Grid&gt;
  &lt;MotionDetectionRegionList&gt;
  &lt;sensitivityLevel&gt;0&lt;/sensitivityLevel&gt;
  &lt;/MotionDetectionRegionList&gt;
  &lt;/MotionDetection&gt;
  
  INFO:hikvision.api:Current motion detection state? enabled: false
  WARNING:hikvision.api:sensitivityLevel is 0.
  INFO:hikvision.api:sensitivityLevel now set to 1
  INFO:hikvision.api:Connected OK!
  INFO:hikvision.api:Camera firmaward version: V5.4.3
  INFO:hikvision.api:Motion Detection enabled: False
  """
  
  #The method:
  """
  hik_camera.__class__(                    hik_camera.__setattr__(
  hik_camera.__delattr__(                  hik_camera.__sizeof__(
  hik_camera.__dict__                      hik_camera.__str__(
  hik_camera.__dir__(                      hik_camera.__subclasshook__(
  hik_camera.__doc__                       hik_camera.__weakref__
  hik_camera.__eq__(                       hik_camera._base
  hik_camera.__format__(                   hik_camera._host
  hik_camera.__ge__(                       hik_camera._password
  hik_camera.__getattribute__(             hik_camera._sensitivity_level
  hik_camera.__gt__(                       hik_camera._username
  hik_camera.__hash__(                     hik_camera._xml_namespace
  hik_camera.__init__(                     hik_camera.disable_motion_detection(
  hik_camera.__le__(                       hik_camera.enable_motion_detection(
  hik_camera.__lt__(                       hik_camera.get_about(
  hik_camera.__module__                    hik_camera.get_version(
  hik_camera.__ne__(                       hik_camera.is_motion_detection_enabled(
  hik_camera.__new__(                      hik_camera.motion_url
  hik_camera.__reduce__(                   hik_camera.put_motion_detection_xml(
  hik_camera.__reduce_ex__(                hik_camera.xml_motion_detection_off
  hik_camera.__repr__(                     hik_camera.xml_motion_detection_on
  """
  hik_camera
  #&lt;hikvision.api.CreateDevice object at 0x7fb09183ab38&gt;
  </code></pre>
  
  <p>With this code I can´t obtain a frame.</p>
  
  <p>Other options:</p>
  
  <pre><code>camera = requests.get('http://192.168.1.64', auth=('admin', contrasenia), stream=True)
  #INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.64
  #DEBUG:requests.packages.urllib3.connectionpool:"GET / HTTP/1.1" 200 480
  chunk = camera.iter_content(chunk_size=1024)
  chunk
  #&lt;generator object iter_slices at 0x7fb090b7a150&gt;
  bytes += bytes()
  #Traceback (most recent call last):
  #  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  #TypeError: unsupported operand type(s) for +=: 'type' and 'bytes'
  </code></pre>
  
  <p>Other:</p>
  
  <pre><code>stream = urllib.request.urlopen("http://192.168.1.64")
  #&lt;http.client.HTTPResponse object at 0x7fb090b82320&gt;
  </code></pre>
  
  <p>Other:</p>
  
  <pre><code>out_cv2 = cv2.VideoCapture('http://192.168.1.64')
  #&lt;VideoCapture 0x7fb090b6dc10&gt;
  cv2.imshow(out_cv2)
  #Traceback (most recent call last):
  #  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  #TypeError: Required argument 'mat' (pos 2) not found
  ret, frame = out_cv2.read()
  cv2.imshow('out', frame)
  #OpenCV Error: Assertion failed (size.width&gt;0 &amp;&amp; size.height&gt;0) in imshow, file /io/opencv/modules/highgui/src/window.cpp, line 304
  #Traceback (most recent call last):
  #  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  #cv2.error: /io/opencv/modules/highgui/src/window.cpp:304: error: (-215) size.width&gt;0 &amp;&amp; size.height&gt;0 in function imshow
  ret
  #False
  frame
  #
  </code></pre>
  
  <p>Other: </p>
  
  <pre><code>from requests.auth import HTTPBasicAuth
  requ = requests.get('http://192.168.1.64', auth=HTTPBasicAuth('admin', contrasenia), stream=True)
  out_file = open('img.png', 'wb')
  shutil.copyfileobj(requ.raw, out_file)
  #The file is empty
  </code></pre>
  
  <p>This code is from other post with similar problem but I can't use it to get my objetive. What can I do?</p>