Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open a specific device with Nite2.UserTracker(device) #1

Open
llynch opened this issue May 28, 2014 · 0 comments
Open

Open a specific device with Nite2.UserTracker(device) #1

llynch opened this issue May 28, 2014 · 0 comments

Comments

@llynch
Copy link

llynch commented May 28, 2014

using this version of openni and nite:

OniVersion(major = 2, minor = 2, maintenance = 0, build = 30)
NiteVersion(major = 2, minor = 2, maintenance = 0, build = 10)

consider this code:

devices = openni2.Device.open_all()
userTracker = nite2.UserTracker(devices[1]) # warning will always fail with device use None

I have found a fix. In fact it is the python DevStruct that does not match the one in c++.
I have made a work around here, note that sensors_info is not affected so some improvement could be done there.
line 186 in nite2.py

class _NiteDevStruct(ctypes.Structure):
    """
    PlaybackControl* m_pPlaybackControl;

    OniDeviceHandle m_device;
    DeviceInfo m_deviceInfo;
    SensorInfo m_aSensorInfo[ONI_MAX_SENSORS];

    bool m_isOwner;
    """

    _fields_ = [
        ("pPlaybackControl", ctypes.c_void_p),
        ("device", openni2.c_api.OniDeviceHandle),

        ("device_info", openni2.c_api.OniDeviceInfo),
        ("sensor_info", openni2.c_api.OniSensorInfo * 10),

        ("is_owner", ctypes.c_bool)
    ]

class UserTracker(HandleObject):
    def __init__(self, device):
        handle = c_api.NiteUserTrackerHandle()
        if not device:
            c_api.niteInitializeUserTracker(ctypes.byref(handle))
        else:
            self._devstruct = _NiteDevStruct()
            self._devstruct.pPlaybackControl = None
            self._devstruct.device = device._handle
            self._devstruct.device_info = device.get_device_info()
            #self._devstruct.sensor_info = device.get_sensor_infos(sensor_type)
            self._devstruct.is_owner = True

            c_api.niteInitializeUserTrackerByDevice(ctypes.byref(self._devstruct), ctypes.byref(handle))

        HandleObject.__init__(self, handle)
        _registered_user_trackers.add(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant