none
How does the NUI_HAND_EVENT_TYPE field work in C++ ? RRS feed

  • Question

  • I have been following the thread titled "Kinect Interactions", and I have successfully implemented the Interaction Client interface, opened the Interaction Stream and the Interaction Frames are updating properly.

    My problem is that the NUI_HAND_EVENT_TYPE field for each tracked hand never changes from NUI_HAND_EVENT_TYPE_NONE.

    Do I need to make a handle and run CreateEvent() to wait for it in the way that we do for Depth and Skeleton Frames? I'm not sure if I'm on the right track or not.

    It seems that others have been running in to the same problem and I haven't found anything in the documentation that addresses it. 

    Also, does the sensor need to be running in Near Mode for any particular interaction features to work? 
    • Edited by D.C. Sweet Wednesday, April 10, 2013 10:00 PM
    Wednesday, April 10, 2013 9:54 PM

Answers

  • Take a look at this thread: http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/45eb3409-ad15-44f2-8b15-7a1b8054d31f

    Maybe it helps you. Also in my application it works with or without near mode! My initialization looks like this:

            HRESULT hr = NUISensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON | NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX); 
    
    		if (SUCCEEDED(hr))
    		{
    			mInteractionClient = new interactionClient();
    
    			hr = NuiCreateInteractionStream(NUISensor,mInteractionClient, &mInteractionStream);
    
    			if(FAILED(hr))
    				return;
    			m_hNextHandFrameEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    			hr = mInteractionStream->Enable(m_hNextHandFrameEvent);
    
    			if(FAILED(hr))
    				return;
    
            }

    Hope this helps..

    Cheers



    • Edited by Kinecticuz Thursday, April 11, 2013 1:18 PM
    • Marked as answer by D.C. Sweet Friday, April 12, 2013 6:38 PM
    Thursday, April 11, 2013 1:17 PM

All replies

  • I'm having the exact same issue. It always says each hand is NUI_HAND_EVENT_TYPE_NONE. It never returns NUI_HAND_EVENT_TYPE_GRIP or NUI_HAND_EVENT_TYPE_GRIPRELEASE.
    Wednesday, April 10, 2013 9:59 PM
  • Take a look at this thread: http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/45eb3409-ad15-44f2-8b15-7a1b8054d31f

    Maybe it helps you. Also in my application it works with or without near mode! My initialization looks like this:

            HRESULT hr = NUISensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON | NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX); 
    
    		if (SUCCEEDED(hr))
    		{
    			mInteractionClient = new interactionClient();
    
    			hr = NuiCreateInteractionStream(NUISensor,mInteractionClient, &mInteractionStream);
    
    			if(FAILED(hr))
    				return;
    			m_hNextHandFrameEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    			hr = mInteractionStream->Enable(m_hNextHandFrameEvent);
    
    			if(FAILED(hr))
    				return;
    
            }

    Hope this helps..

    Cheers



    • Edited by Kinecticuz Thursday, April 11, 2013 1:18 PM
    • Marked as answer by D.C. Sweet Friday, April 12, 2013 6:38 PM
    Thursday, April 11, 2013 1:17 PM
  • Thanks, Kinecticuz. I got it figured out. The problem (I think) is that I was initializing the depth stream with NUI_INITIALIZE_FLAG_USES_DEPTH instead of NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX. 

    After figuring out that I also had to change the eImageType input of NuiImageStreamOpen() to NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX for the depth stream to open properly, the NUI_HAND_EVENT_TYPE did indeed start responding. 


    Friday, April 12, 2013 6:38 PM
  • D.C Sweet. The NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX and NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX  flags were my issue too. 
    Monday, April 15, 2013 3:55 PM
  • hi m_gross,

    hr = NuiCreateInteractionStream(m_pNuiSensor,m_interactionClient, &m_interactionStream);

    how could I build this function?

    I got below error. It looks like need to import some library

    1>SkeletonBasics.obj : error LNK2019: unresolved external symbol __imp__NuiCreateInteractionStream@12 referenced in function "private: long __thiscall CSkeletonBasics::CreateFirstConnected(void)" (?CreateFirstConnected@CSkeletonBasics@@AAEJXZ)
    1>D:\Project\Kinect\SkeletonBasics1.7_HandGrip\Debug\SkeletonBasics-D2D.exe : fatal error LNK1120: 1 unresolved externals

    Tuesday, April 16, 2013 4:11 AM
  • I could build it :), missing some dll, sorry for bothering you all 
    Tuesday, April 16, 2013 8:43 AM
  • Hi King Nguyen,

    I tried to build your code with win32. How could I build the function????? I got the error as following:

    1>Interactions.obj : error LNK2019: unresolved external symbol __imp__NuiCreateInteractionStream@12 referenced in function "public: long __thiscall CSkeletonBasics::CreateFirstConnected(void)" (?CreateFirstConnected@CSkeletonBasics@@QAEJXZ)

    Then I tried to create the object of CInteractionClient at createfirstconnnected()

    mInteractionClient = new CInteractionClient ();

    I included the KinectInteraction170_64.lib at the project properties(Linker-> Input).Is there any problem in my code? How can I build it???? Is I need to add any dll?? You told like missed out some dll. What dll need to include???? How can I add??

    Please help me!!!!!

    void CSkeletonBasics::Update()
    {
        if (NULL == m_pNuiSensor)
        {
            return;
        }
    if (WAIT_OBJECT_0 == WaitForSingleObject(m_hNextDepthFrameEvent, 0))
    {
    ProcessDepth();
    }

        if ( WAIT_OBJECT_0 == WaitForSingleObject(m_hNextSkeletonEvent, 0) )
        {
            ProcessSkeleton();
        }
    if ( WAIT_OBJECT_0 == WaitForSingleObject(m_hNextInteractionEvent, 0) )
        {
       ProcessInteraction();
        }
    }



    class CIneractionClient:public INuiInteractionClient
    {
    public:
    CIneractionClient()
    {;}
    ~CIneractionClient()
    {;}


    STDMETHOD(GetInteractionInfoAtLocation)(THIS_ DWORD skeletonTrackingId, NUI_HAND_TYPE handType, FLOAT x, FLOAT y, _Out_ NUI_INTERACTION_INFO *pInteractionInfo)
    {        
     if(pInteractionInfo)
    {
     pInteractionInfo->IsPressTarget         = false;
     pInteractionInfo->PressTargetControlId  = 0;
     pInteractionInfo->PressAttractionPointX = 0.f;
     pInteractionInfo->PressAttractionPointY = 0.f;
     pInteractionInfo->IsGripTarget          = true;
     return S_OK;
    }
    return E_POINTER;
      
     //return S_OK; 
     
    }

    STDMETHODIMP_(ULONG)    AddRef()                                    { return 2;     }
    STDMETHODIMP_(ULONG)    Release()                                   { return 1;     }
    STDMETHODIMP            QueryInterface(REFIID riid, void **ppv)     { return S_OK;  }

    };
    CIneractionClient m_nuiIClient;
    INuiInteractionStream *m_nuiIStream;
    .................................................................................................................................
    HRESULT CSkeletonBasics::CreateFirstConnected()
    {
        INuiSensor * pNuiSensor;

        int iSensorCount = 0;
        HRESULT hr = NuiGetSensorCount(&iSensorCount);
        if (FAILED(hr))
        {
            return hr;
        }

        // Look at each Kinect sensor
        for (int i = 0; i < iSensorCount; ++i)
        {
            // Create the sensor so we can check status, if we can't create it, move on to the next
            hr = NuiCreateSensorByIndex(i, &pNuiSensor);
            if (FAILED(hr))
            {
                continue;
            }

            // Get the status of the sensor, and if connected, then we can initialize it
            hr = pNuiSensor->NuiStatus();
            if (S_OK == hr)
            {
                m_pNuiSensor = pNuiSensor;
                break;
            }

            // This sensor wasn't OK, so release it since we're not using it
            pNuiSensor->Release();
        }

        if (NULL != m_pNuiSensor)
        {
            // Initialize the Kinect and specify that we'll be using skeleton
            //hr = m_pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON); 
            hr = m_pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX|  NUI_INITIALIZE_FLAG_USES_COLOR|  NUI_INITIALIZE_FLAG_USES_SKELETON); 
            if (SUCCEEDED(hr))
            {

      m_hNextDepthFrameEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
      m_pDepthStreamHandle = NULL;

      hr = m_pNuiSensor->NuiImageStreamOpen( NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX, NUI_IMAGE_RESOLUTION_640x480, 0, 2,  m_hNextDepthFrameEvent, &m_pDepthStreamHandle);
      if( FAILED( hr ) )
      {
    return hr;
      }
                // Create an event that will be signaled when skeleton data is available
                m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
                // Open a skeleton stream to receive skeleton data
                hr = m_pNuiSensor->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, NUI_SKELETON_TRACKING_FLAG_ENABLE_IN_NEAR_RANGE); 


    m_hNextInteractionEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    hr = NuiCreateInteractionStream(m_pNuiSensor,(INuiInteractionClient *)&m_nuiIClient, &m_nuiIStream);

                            //m_nuiIClient= new CInteractionClient ();
                            //hr = NuiCreateInteractionStream(m_pNuiSensor,m_nuiIClient, &m_nuiIStream);

    if(FAILED(hr))
    return hr;
    hr = m_nuiIStream->Enable(m_hNextInteractionEvent);

    if(FAILED(hr))
    return hr;

            }
        }

        if (NULL == m_pNuiSensor || FAILED(hr))
        {
            SetStatusMessage(L"No ready Kinect found!");
            return E_FAIL;
        }

        return hr;
    }
    Saturday, June 1, 2013 4:04 AM
  • You have to copy KinectInteraction170_32/64.dll to your <Project folder>\Debug\

    Then you have to link the dependencies (KinectInteraction.h)

    Here're some references that I use to fix that error

    http://stackoverflow.com/questions/9928238/unresolved-external-symbol-no-idea

    http://stackoverflow.com/questions/133698/why-does-fatal-error-lnk1104-cannot-open-file-c-program-obj-occur-when-i-c


    Monday, June 3, 2013 2:58 AM
  • vivekmk - please post a new question and do not pile onto old threads. You are duplicating questions that have already been asked, see

    http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/cd013b55-6bea-4985-92d0-b974512ad90e

    Monday, June 3, 2013 5:51 PM