ubuntu20.04安装pylibfreenect2(用python接口控制kinectv2)

ubuntu20.04安装pylibfreenect2(用python接口控制kinectv2)

上一篇博客安装了IAI Kinect2来控制kinectv2相机,但是python接口控制的例子好难找到,后面就安装pylibfreenect2来代替,按照教程安装

安装之前需要确保你已经安装了libfreenect2驱动

教程说这个库最高适配python3.5,但是我的安装环境是python3.9,好像也没什么问题

下载仓库
git clone https://github.com/r9y9/pylibfreenect2.git
cd pylibfreenect2
python setup.py install
报错1

在执行安装命令python setup.py install时,会报错,需要根据教程中

You have set LIBFREENECT2_INSTALL_PREFIX environmental variable (default: /usr/local/) and confirm that ${LIBFREENECT2_INSTALL_PREFIX}include/libfreenect2/config.h exists.

LIBFREENECT2_INSTALL_PREFIX设置为你安装目录下的your path/include/libfreenect2/config.h文件中的父路径(your path),一般安装完libfreenect2后在home路径下有freenect2文件夹,将上面的your path改为该文件夹路径即可

方法一:编辑~/.bashrc文件,export变量LIBFREENECT2_INSTALL_PREFIX为你的路径

方法二:直接修改setup.py中的默认值,将/usr/local/替换为/home/[name]/freenect2/,[name]为你的ubuntu用户名

这样就可以通过python setup.py install

报错2

ImportError: libfreenect2.so.0.2: cannot open shared object file: No such file or directory

解决办法:

sudo ln -s $HOME/freenect2/lib/libfreenect2.so.0.2 /usr/lib/libfreenect2.so.0.2

猜你喜欢

转载自blog.csdn.net/weixin_48319333/article/details/129761083