ykoneee / k4a-python

A Python wrapper for Azure-Kinect-Sensor-SDK
MIT License
8 stars 1 forks source link

Error when running example code #1

Open martinakos opened 4 years ago

martinakos commented 4 years ago

First of all, thanks for this library!

I installed it following your instructions and it seems it installed correctly. However, when I run your example code I get this error:

TypeError: unbound method get_installed_count() must be called with Device instance as first argument (got nothing instead)

when running the line

print(pyk4a.Device.get_installed_count())

and similar error:

TypeError: unbound method open() must be called with Device instance as first argument (got int instance instead)

when running:

device=pyk4a.Device.open(pyk4a.K4A_DEVICE_DEFAULT)

Do you know what could be the problem?

martinakos commented 4 years ago

The error above happens in python2.7. I've been able to run the example code successfully in python3.5. Still, because of other dependencies I need to use python2.7. how could this error be solved for python2.7?

martinakos commented 4 years ago

I found a solution. I changed some of the .def in the pyk4a.cpp file for .def_static and rebuild, then it work for python2.7 too. More specifically I changed the lines 313,314

            .def_static("open", &pyk4adevice::open)
            .def_static("get_installed_count", &pyk4adevice::get_installed_count)