-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathviewer_depth.py
37 lines (30 loc) · 875 Bytes
/
viewer_depth.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
import cv2
import numpy as np
import pyk4a
from helpers import colorize
from pyk4a import Config, PyK4A
def main():
k4a = PyK4A(
Config(
color_resolution=pyk4a.ColorResolution.OFF,
depth_mode=pyk4a.DepthMode.NFOV_UNBINNED,
synchronized_images_only=False,
)
)
k4a.start()
# getters and setters directly get and set on device
k4a.whitebalance = 4500
assert k4a.whitebalance == 4500
k4a.whitebalance = 4510
assert k4a.whitebalance == 4510
while True:
capture = k4a.get_capture()
if np.any(capture.depth):
cv2.imshow("k4a", colorize(capture.depth, (None, 5000), cv2.COLORMAP_HSV))
key = cv2.waitKey(10)
if key != -1:
cv2.destroyAllWindows()
break
k4a.stop()
if __name__ == "__main__":
main()