forked from jdibenes/hl2ss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_stream_rm_vlc.py
85 lines (67 loc) · 2.25 KB
/
client_stream_rm_vlc.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#------------------------------------------------------------------------------
# This script receives video from one of the HoloLens sideview grayscale
# cameras and plays it. The camera resolution is 640x480 @ 30 FPS. The stream
# supports three operating modes: 0) video, 1) video + rig pose, 2) query
# calibration (single transfer).
# Press esc to stop.
#------------------------------------------------------------------------------
from pynput import keyboard
import cv2
import hl2ss_imshow
import hl2ss
import hl2ss_lnm
# Settings --------------------------------------------------------------------
# HoloLens address
host = "192.168.1.7"
# Port
# Options:
# hl2ss.StreamPort.RM_VLC_LEFTFRONT
# hl2ss.StreamPort.RM_VLC_LEFTLEFT
# hl2ss.StreamPort.RM_VLC_RIGHTFRONT
# hl2ss.StreamPort.RM_VLC_RIGHTRIGHT
port = hl2ss.StreamPort.RM_VLC_LEFTFRONT
# Operating mode
# 0: video
# 1: video + rig pose
# 2: query calibration (single transfer)
mode = hl2ss.StreamMode.MODE_1
# Framerate denominator (must be > 0)
# Effective framerate is framerate / divisor
divisor = 1
# Video encoding profile and bitrate (None = default)
profile = hl2ss.VideoProfile.H265_MAIN
bitrate = None
#------------------------------------------------------------------------------
if (mode == hl2ss.StreamMode.MODE_2):
data = hl2ss_lnm.download_calibration_rm_vlc(host, port)
print('Calibration data')
print('Image point to unit plane')
print(data.uv2xy)
print('Extrinsics')
print(data.extrinsics)
print('Undistort map')
print(data.undistort_map)
print('Intrinsics (undistorted only)')
print(data.intrinsics)
quit()
enable = True
def on_press(key):
global enable
enable = key != keyboard.Key.esc
return enable
listener = keyboard.Listener(on_press=on_press)
listener.start()
client = hl2ss_lnm.rx_rm_vlc(host, port, mode=mode, divisor=divisor, profile=profile)
client.open()
while (enable):
data = client.get_next_packet()
print(f'Frame captured at {data.timestamp}')
print(f'Sensor Ticks: {data.payload.sensor_ticks}')
print(f'Exposure: {data.payload.exposure}')
print(f'Gain: {data.payload.gain}')
print(f'Pose')
print(data.pose)
cv2.imshow('Video', data.payload.image)
cv2.waitKey(1)
client.close()
listener.join()