Created
August 19, 2019 13:01
-
-
Save bmabir17/c7b44b97e27df17b9e184f0daa562a23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:[email protected]: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