forked from smartsenselab/sensecam-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
65 lines (43 loc) · 1.46 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import cv2
import sys
import threading
from sensecam_control import vapix_control
ip = '000.000.000.000'
login = 'login'
password = 'password'
exit_program = 0
def event_keyboard(k):
global exit_program
if k == 27: # esc
exit_program = 1
elif k == ord('w') or k == ord('W'):
X.relative_move(None, 1, None)
elif k == ord('a') or k == ord('A'):
X.relative_move(-1, None, None)
elif k == ord('s') or k == ord('S'):
X.relative_move(None, -1, None)
elif k == ord('d') or k == ord('D'):
X.relative_move(1, None, None)
elif k == ord('h') or k == ord('H'):
X.go_home_position()
def capture(ip_camera):
global exit_program
#url http login axis camera
ip2 = 'http://' + login + ':' + password + '@' + ip_camera + '/mjpg/1/video.mjpg?'
#url rtsp axis camera
#ip2 = 'rtsp://' + login + ':' + password + '@' + ip_camera + '/axis-media/media.amp'
cap = cv2.VideoCapture(ip2)
while True:
ret, frame = cap.read()
if ret is not False:
break
while True:
ret, frame = cap.read()
if exit_program == 1:
sys.exit()
#cv2.namedWindow('Camera', cv2.WINDOW_NORMAL)
cv2.imshow('Camera', frame)
event_keyboard(cv2.waitKey(1) & 0xff)
X = vapix_control.CameraControl(ip, login, password)
t = threading.Thread(target=capture, args=(ip,))
t.start()