原生Kinect互动 [英] Native Kinect Interaction

查看:98
本文介绍了原生Kinect互动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 在我们公司,我们使用原生C ++ kinect SDK。我正在努力开展手工互动,但我已经陷入了一些细节。我没有在SDK和Internet中找到任何示例如何使用本机API进行交互,几乎没有文档。
SDK C#和托管C ++中有2个例子,但是没有原生的C ++示例。

  in our company we use native C++ kinect SDK. I'm trying to get to work hand interaction but I've stuck in some details. I didn't found any example in SDK and in Internet how to use the native API for interaction and there is little to no documentation. There are 2 examples in SDK C# and managed C++ but there is no native C++ example.

 到目前为止我所做的是我用过的GetKinectCoreWindowForCurrentThread获取核心窗口我使用  SubscribePointerEntered / Moved / Exited成功订阅了指针事件。我正确地接受按摩循环中的后遗症。但是我无法做的
是在GestureRecognizer中正确注册处理程序,例如RegisterManipulationStartedHandler。以下是我尝试实现IKinectGestureRecognizerManipulationHandler并注册的方法:

 What I've done so far is a I've used GetKinectCoreWindowForCurrentThread to get core window I subscribed successfully to pointer events using SubscribePointerEntered/Moved/Exited. I'm receiving the evtents in massage loop correctly. But what I was unable to do is to correctly register handlers in GestureRecognizer for example RegisterManipulationStartedHandler. Here is how I tried to implement the IKinectGestureRecognizerManipulationHandler and register it:

class myHandler : public IKinectGestureRecognizerManipulationHandler
{
    virtual HRESULT STDMETHODCALLTYPE OnManipulationStarted(IKinectManipulationStartedEventArgs *args)
    {
        DebugTrace(L"Manipulation started");
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE OnManipulationUpdated(IKinectManipulationUpdatedEventArgs *args)
    {
        DebugTrace(L"Manipulation updated");
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE OnManipulationInertiaStarting(IKinectManipulationInertiaStartingEventArgs *args)
    {
        DebugTrace(L"Manipulation inertia starting");
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE OnManipulationCompleted(IKinectManipulationCompletedEventArgs *args)
    {
        DebugTrace(L"Manipulation completed");
        return S_OK;
    }

    HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID * ppvObj)
    {
        return E_NOINTERFACE;
    }

    ULONG STDMETHODCALLTYPE AddRef()
    {
        return 0;
    }
    ULONG STDMETHODCALLTYPE Release()
    {
        return 0;
    }
};

myHandler g_manipulatorHandler;

HRESULT CBodyBasics::InitializeDefaultSensor()
{
    HRESULT hr;

    hr = GetDefaultKinectSensor(&m_pKinectSensor);
    if (FAILED(hr))
    {
        return hr;
    }

    if (m_pKinectSensor)
    {
        // Initialize the Kinect and get coordinate mapper and the body reader
        IBodyFrameSource* pBodyFrameSource = NULL;

        hr = m_pKinectSensor->Open();

        ...

        if (SUCCEEDED(hr))
        {
            hr = CreateKinectGestureRecognizer(&m_pGestureRecognizer);
        }

        if (SUCCEEDED(hr))
        {
            hr = m_pGestureRecognizer->RegisterManipulationStartedHandler(&g_manipulatorHandler);
        }

        SafeRelease(pBodyFrameSource);
    }

    if (!m_pKinectSensor || FAILED(hr))
    {
        SetStatusMessage(L"No ready Kinect found!", 10000, true);
        return E_FAIL;
    }

    return hr;
}

对于测试的建议,我跳过了QueryInterface,AddRef和Release的实现,因为它们根本没有被调用,我在debuger中进行了双重检查。我试图通过关闭我的手触发操作手势,但我仍然没有从IKinectGestureRecognizerManipulationHandler获得任何调试
消息。可能会正确检测到关闭的手势,因为SDK中的BodyBasic构建示例会在同一时间内正确检测到关闭的手。

For the propose of testing I skipped implementation of QueryInterface, AddRef and Release because they are not called at all which I double checked in debuger. I tried to trigger the manipulation gesture by closing my hand but I still don't get any debug messages from IKinectGestureRecognizerManipulationHandler. The closed hand gesture is likely to be detected correctly because this example build on BodyBasic from SDK detects closed hand correctly in the same time.

可以请某人提供示例或帮助我解决此问题问题

Can please someone provide an example or help me with this specific problem

提前致谢,

Pawel Dondziak

Pawel Dondziak

推荐答案

注册调用成功了吗?什么是HR值,因为我没有看到你检查过?

Did the call to register succeed? What was the HR value since I don't see that you checked that?

通常情况下,您会将此界面附加到某种类型的UIElement(如按钮)上,因此我假设这是myHandler将会是什么。您应该实施QueryInterface,并且至少从AddRef返回1,因为您不知道使用此组件的基础代码如何,因为您不是
。 它可能正在执行QueryInterface用于返回指向实例化对象的指针,但是您返回E_NOINTERFACE而不是返回
返回指针。 

Typically you are going to attach this interface onto some type of UIElement like a button, so i assume that is what myHandler is going to be. You should be implementing QueryInterface and at least returning 1 from AddRef as you are not following the COM convention since you don't know how the underlying code using this component. It may be doing a QueryInterface for you to return a pointer to the instantiated object but you are returning E_NOINTERFACE and not populating the return pointer. 


这篇关于原生Kinect互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆