Ubuntu16.04環境下安裝Azure Kinect和使用Open3D通過python來調用相機的記錄

系統:Ubuntu16.04
安裝參考:

安裝

此路不通

此方法是官方提供的方法,親測不好用,就不要再嘗試了!
安裝參考網址: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()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章