How to install pylibfreenect2

154 Views Asked by At

I'm trying to follow instruction link and at the step

python setup.py install

I get following error: Do you know what I'm doing wrong?

PS C:\Users\lukin\Downloads\pylibfreenect2-master\pylibfreenect2-master> python setup.py
python : C:\Users\lukin\Downloads\pylibfreenect2-master\pylibfreenect2-master\setup.py:44: DeprecationWarning: distutils Version classes are deprecated. 
Use packaging.version instead.
At line:1 char:1
+ python setup.py
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\lukin\...ersion instead.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
  _CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver)
C:\Users\lukin\AppData\Local\Programs\Python\Python311\Lib\site-packages\Cython\Compiler\Main.py:381: FutureWarning: Cython directive 'language_level' not 
set, using '3str' for now (Py3). This has changed from earlier releases! File: 
C:\Users\lukin\Downloads\pylibfreenect2-master\pylibfreenect2-master\pylibfreenect2\libfreenect2.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
warning: pylibfreenect2\libfreenect2.pyx:1405:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime 
conditions or C macros instead. See https://github.com/cython/cython/issues/4310
warning: pylibfreenect2\libfreenect2.pyx:1408:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime 
conditions or C macros instead. See https://github.com/cython/cython/issues/4310
warning: pylibfreenect2\libfreenect2.pyx:1412:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime 
conditions or C macros instead. See https://github.com/cython/cython/issues/4310
Error compiling Cython file:
------------------------------------------------------------
...
# Workaround for use of pointer type in reinterpret_cast
# https://groups.google.com/forum/#!msg/cython-users/FgEf7Vrx4AM/dm7WY_bMCAAJ
ctypedef uint8_t* uint8_pt
# Import libfreenect2 definitions
from libfreenect2 cimport libfreenect2
^
------------------------------------------------------------
pylibfreenect2\libfreenect2.pyx:171:0: 'libfreenect2.pxd' not found
Error compiling Cython file:
------------------------------------------------------------
...
# Workaround for use of pointer type in reinterpret_cast
# https://groups.google.com/forum/#!msg/cython-users/FgEf7Vrx4AM/dm7WY_bMCAAJ
ctypedef uint8_t* uint8_pt
# Import libfreenect2 definitions
from libfreenect2 cimport libfreenect2
^
------------------------------------------------------------
pylibfreenect2\libfreenect2.pyx:171:0: 'libfreenect2\libfreenect2.pxd' not found
Error compiling Cython file:
------------------------------------------------------------

I moved few steps further I could not resolve the issue above so I moved setup.py in the pylibfreenect2 folder

And changed this code in setup.py

ext_modules = cythonize(
    [Extension(
        name="pylibfreenect2.libfreenect2",
        sources=[
            join("pylibfreenect2", "libfreenect2" + ext),
        ],

to this

ext_modules = cythonize(
    [Extension(
        name="pylibfreenect2.libfreenect2",
        sources=[
            join("libfreenect2" + ext),
        ],

That builds the module and I managed to install it But when I'm running sample it fails on the import. Probably that has to do with the install path but I don't understand how to fix it.

from pylibfreenect2 import Freenect2

I get the error

ImportError: cannot import name 'Freenect2' from 'pylibfreenect2' (unknown location)

I tried a lot of things but cannot resolve the error Probably that has to do with the install path but I don't understand how to fix it.

libfreenect2-0.2.0-usbdk-vs2015-x64 is setup correctly. When I start Protonect.exe it shows images from each Kinect

2

There are 2 best solutions below

0
On

Windows

  1. First install vcpkg

  2. Install pylibfreenect2

    • Open environment variables and add libfreenect path from the vcpkg installed as LIBFREENECT2_INSTALL_PREFIX E.g: LIBFREENECT2_INSTALL_PREFIX = F:\ViewShed\vcpkg\installed\x64-windows
    • Add another environment variable as: E.g: pylibfreenect2 = F:\ViewShed\vcpkg\installed\x64-windows\include\libfreenect2
    • pip install Cython==0.29.36
    • pip install pylibfreenect2
0
On

Open terminal and write: pip install pylibfreenect2