-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
52 lines (44 loc) · 1.06 KB
/
example.py
File metadata and controls
52 lines (44 loc) · 1.06 KB
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
from robobopy_videostream.RoboboVideo import RoboboVideo
from robobopy.Robobo import Robobo
import cv2
import signal
import sys
IP = "YOUR_IP_GOES_HERE"
rob = Robobo(IP)
videoStream = RoboboVideo(IP)
def cleanup():
try:
videoStream.disconnect()
except:
pass
try:
rob.disconnect()
except:
pass
cv2.destroyAllWindows()
print("Exited cleanly.")
sys.exit(0)
def signal_handler(sig, frame):
cleanup()
signal.signal(signal.SIGINT, signal_handler)
def main():
print("Starting test app")
rob.connect()
videoStream.connect()
rob.startStream()
print("Showing images")
i = 0
last_ts = 0
while True:
i += 1
frame, timestamp, sync_id, frame_id = videoStream.getImageWithMetadata()
if timestamp != last_ts:
print(timestamp, frame_id, sync_id)
cv2.imshow('smartphone camera', frame)
key = cv2.waitKey(1) & 0xFF
if key == 27: # Escape key
break
last_ts = timestamp
cleanup()
if __name__ == "__main__":
main()