-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_view.py
33 lines (26 loc) · 1.1 KB
/
test_view.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
"""
Author: Konstantinos Angelopoulos
Date: 04/02/2020
All rights reserved.
Feel free to use and modify and if you like it give it a star.
Test the kinect's rgb and depth view to find the optimum location
"""
from pykinect2.PyKinectV2 import *
from pykinect2 import PyKinectV2
from pykinect2 import PyKinectRuntime
import cv2
import numpy as np
kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Depth | PyKinectV2.FrameSourceTypes_Color)
while True:
color_frame = kinect.get_last_color_frame()
colorImage = color_frame.reshape((kinect.color_frame_desc.Height, kinect.color_frame_desc.Width, 4)).astype(np.uint8)
colorImage = cv2.flip(colorImage, 1)
cv2.imshow('Test Color View', cv2.resize(colorImage, (int(1920/2.5), int(1080/2.5))))
depth_frame = kinect.get_last_depth_frame()
depth_img = depth_frame.reshape((kinect.depth_frame_desc.Height, kinect.depth_frame_desc.Width)).astype(np.uint8)
depth_img = cv2.flip(depth_img, 1)
cv2.imshow('Test Depth View', depth_img)
# Quit using q
if cv2.waitKey(1) & 0xff == ord('q'):
break
cv2.destroyAllWindows()