Skip to content

Instantly share code, notes, and snippets.

@bmabir17
Created August 19, 2019 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmabir17/c7b44b97e27df17b9e184f0daa562a23 to your computer and use it in GitHub Desktop.
Save bmabir17/c7b44b97e27df17b9e184f0daa562a23 to your computer and use it in GitHub Desktop.
from hikvisionapi import Client
import cv2
import numpy as np
cam = Client('http://192.168.1.2','admin','admin123',timeout=1)
cap=cv2.VideoCapture('rtsp://admin:admin123@192.168.1.2:554/main/av_stream')
#response = cam.System.deviceInfo(method='get')
#print(response)
#motion_detection_info = cam.System.Video.inputs.channels[1].motionDetection(method='get')
#print(motion_detection_info)
while True:
try:
response = cam.Event.notification.alertStream(method='get', type='stream')
if response:
_,frame=cap.read()
# print (response)
# # Get and save picture from camera
# response = cam.Streaming.channels[102].picture(method='get', type='opaque_data')
# #with open('screen.jpg', 'wb') as f:
# for chunk in response.iter_content(chunk_size=1024):
# if chunk:
# #f.write(chunk)
# print(chunk)
# img= cv2.imdecode(np.fromstring(chunk,np.uint8),cv2.IMREAD_COLOR)
# cv2.imshow("ipMotion",img)
# if cv2.waitKey(1) & 0xFF==ord('q'):
# break
cv2.imshow("ipMotion",frame)
if cv2.waitKey(1) & 0xFF==ord('q'):
break
except Exception as e:
print(e)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment