From bc36bbb0a3df5ac5b8224badd56d3a5a4b4aabf2 Mon Sep 17 00:00:00 2001 From: nekanat Date: Sat, 10 Oct 2020 21:46:13 +0900 Subject: [PATCH] azure kinect example --- .github/FUNDING.yml | 1 + .../azure_kinect/azure_kinect_pcd_viewer.py | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 examples/python/azure_kinect/azure_kinect_pcd_viewer.py diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..80b4f797 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: neka-nat \ No newline at end of file diff --git a/examples/python/azure_kinect/azure_kinect_pcd_viewer.py b/examples/python/azure_kinect/azure_kinect_pcd_viewer.py new file mode 100644 index 00000000..53ce06f8 --- /dev/null +++ b/examples/python/azure_kinect/azure_kinect_pcd_viewer.py @@ -0,0 +1,45 @@ +import numpy as np +import pyk4a +from pyk4a import Config, PyK4A +import cupoch as cph + +def main(): + k4a = PyK4A( + Config( + color_resolution=pyk4a.ColorResolution.RES_720P, + depth_mode=pyk4a.DepthMode.NFOV_UNBINNED, + synchronized_images_only=True, + ) + ) + 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 + + vis = cph.visualization.Visualizer() + vis.create_window() + pcd = cph.geometry.PointCloud() + frame_count = 0 + while True: + capture = k4a.get_capture() + if not np.any(capture.depth) or not np.any(capture.color): + break + points = capture.depth_point_cloud.reshape((-1, 3)) + colors = capture.transformed_color[..., (2, 1, 0)].reshape((-1, 3)) / 255 + pcd.points = cph.utility.Vector3fVector(points) + pcd.colors = cph.utility.Vector3fVector(colors) + + if frame_count == 0: + vis.add_geometry(pcd) + + vis.update_geometry(pcd) + vis.poll_events() + vis.update_renderer() + frame_count += 1 + k4a.stop() + +if __name__ == "__main__": + main() \ No newline at end of file