Ubuntu16.04环境下安装Azure Kinect和使用Open3D通过python来调用相机的记录

系统:Ubuntu16.04
安装参考:

文章目录

  • 安装
    • 此路不通
    • 第二种尝试
  • 通过Open3D控制azure kinect

安装

此路不通

此方法是官方提供的方法,亲测不好用,就不要再尝试了!
安装参考网址:https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/docs/usage.md

On Linux, binaries are currently available as debian packages. We currently have debian packages available for Ubuntu 18.04.

官方说明Azure Kinect SDK目前支持Ubuntu18.04

对于Ubuntu16.04找到以下安装教程:https://thomasweng.com/azure_kinect_1604/

$ git clone -b release/1.1.x https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git
$ bash ./Azure-Kinect-Sensor-SDK/scripts/bootstrap-ubuntu.sh
# Follow the build steps in https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/release/1.1.x/docs/building.md.
$ cd /Azure-Kinect-Sensor-SDK/
$ mkdir build && cd build
$ cmake .. -GNinja
# 如果出现CMake Error, 参考 https://thomasweng.com/azure_kinect_1604/ 第三步更换cmake版本
$ ninja
# 接下来需要Get a copy of the depthengine binary ‘libdepthengine.so.1.0’
# 我们需要安装'k4a-tools on an Ubuntu 18.04 OS', https://docs.microsoft.com/en-us/azure/Kinect-dk/sensor-sdk-download#linux-installation-instructions
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ sudo apt-add-repository https://packages.microsoft.com/ubuntu/16.04/prod
$ sudo apt-get update
# 出现报错如下
Reading package lists... Done
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.microsoft.com/ubuntu/16.04/prod xenial InRelease' doesn't support architecture 'i386'
# 解决方法
$ cd /etc/apt/
$ vim sources.list
# 将deb https://packages.microsoft.com/ubuntu/16.04/prod xenial main #arch=amd64 更改为 deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main #arch=amd64
然后依旧无法sudo apt install k4a-tools
此路不通

第二种尝试

https://blog.csdn.net/u010497704/article/details/102542570
尝试成功,但是使用open3d来控制azure kinect相机的时候可能会有libk4a.so找不到的情况,再自己设置一下即可。/home/Azure-Kinect-Sensor-SDK/build/bin/libk4a.so

通过Open3D控制azure kinect

可以直接下载Open3D的源码然后cd到/home/kx/Open3D/examples/Python/ReconstructionSystem/sensors/执行python examples/Python/ReconstructionSystem/sensors/azure_kinect_viewer.py --align_depth_to_color
或者直接pip install open3d然后在ipython里运行下面代码:

import open3d as o3d


class ViewerWithCallback:

    def __init__(self, config, device, align_depth_to_color):
        self.flag_exit = False
        self.align_depth_to_color = align_depth_to_color

        self.sensor = o3d.io.AzureKinectSensor(config)
        if not self.sensor.connect(device):
            raise RuntimeError('Failed to connect to sensor')

    def escape_callback(self, vis):
        self.flag_exit = True
        return False

    def run(self):
        glfw_key_escape = 256
        vis = o3d.visualization.VisualizerWithKeyCallback()
        vis.register_key_callback(glfw_key_escape, self.escape_callback)
        vis.create_window('viewer', 1920, 540)
        print("Sensor initialized. Press [ESC] to exit.")

        vis_geometry_added = False
        while not self.flag_exit:
            rgbd = self.sensor.capture_frame(self.align_depth_to_color)
            if rgbd is None:
                continue

            if not vis_geometry_added:
                vis.add_geometry(rgbd)
                vis_geometry_added = True

            vis.update_geometry()
            vis.poll_events()
            vis.update_renderer()

config = o3d.io.AzureKinectSensorConfig()
device = 0
align_depth_to_color = 1
v = ViewerWithCallback(config, device, align_depth_to_color)
v.run()

你可能感兴趣的:(笔记)