none
get_IsTracked doesn't work with openGL RRS feed

  • Question

  • Hello, 

    I'm trying to detect body joints and I'm working with the BodyBasics-D2D sample.

    I simply copy-pasted everything I needed and removed the API windows related stuff because I'm using OpenGL.

    Everything works fine when I'm launching the sample (I'm sure that the problem doesn't come from my kinect or my PC) but when I launch my program, nothing happens, the get_istracked  always returns false.

    Do you have any clue of why it doesn't work?

    Below is my code. I use the init function in my init and the detectbodies in the update.

    thank you very much.

    void BodyTracking::InitKinect()
    {
    	GetDefaultKinectSensor(&m_pKinectSensor);
    	m_pKinectSensor->Open();
    	m_pKinectSensor->get_CoordinateMapper(&m_pCoordinateMapper);
    	IBodyFrameSource* pBodyFrameSource = NULL;
    	m_pKinectSensor->get_BodyFrameSource(&pBodyFrameSource);
    	pBodyFrameSource->OpenReader(&m_pBodyFrameReader);
    	pBodyFrameSource->Release();
    	pBodyFrameSource = NULL;
    }
    
    void BodyTracking::DetectBodies(int windowWidth, int windowHeight)
    {
    
    	IBodyFrame* pBodyFrame = NULL;
    	HRESULT hr = m_pBodyFrameReader->AcquireLatestFrame(&pBodyFrame);
    	if (SUCCEEDED(hr))
    	{
    		IBody* ppBodies[BODY_COUNT] = { 0 };
    		pBodyFrame->GetAndRefreshBodyData(_countof(ppBodies), ppBodies);
    		for (int i = 0; i < BODY_COUNT; ++i)
    		{
    			IBody* pBody = ppBodies[i];
    			if (pBody)
    			{
    				BOOLEAN bTracked = false;
    				pBody->get_IsTracked(&bTracked);
    				//******************problem here***************//
    				if (bTracked)
    				{
    					Joint joints[JointType_Count];
    					Point2D jointPoints[JointType_Count];
    					HandState leftHandState = HandState_Unknown;
    					HandState rightHandState = HandState_Unknown;
    
    					pBody->get_HandLeftState(&leftHandState);
    					pBody->get_HandRightState(&rightHandState);
    
    					pBody->GetJoints(_countof(joints), joints);
    
    					for (int j = 0; j < _countof(joints); ++j)
    					{
    						// Calculate the body's position on the screen
    						DepthSpacePoint depthPoint = { 0 };
    						m_pCoordinateMapper->MapCameraPointToDepthSpace(joints[j].Position, &depthPoint);
    
    						float screenPointX = static_cast<float>(depthPoint.X * windowWidth) / 512;
    						float screenPointY = static_cast<float>(depthPoint.Y * windowHeight) / 424;
    
    						jointPoints[j] = Point2D(screenPointX, screenPointY);
    					}
    
    					
    
    					//i just printf for the moment
    					for (int i = 0; i < JointType_Count; ++i)
    					{
    						printf("found coordinates :   %f,   %f\n", jointPoints[i].x, jointPoints[i].y);
    					}
    				}
    			}
    		}
    	}
    }


    Friday, April 3, 2015 7:42 AM

Answers

  • Did you follow the pattern exactly? Did you release the frames when you were done?

    Carmine Sirignano - MSFT

    • Marked as answer by VulpesZerda Thursday, April 9, 2015 9:14 AM
    Wednesday, April 8, 2015 5:22 PM

All replies

  • Kinect data is independent of UI/graphics framework you might be using. The issue you may be having has to do with your GPU driver not being up to date, see troubleshooting/known issues: https://social.msdn.microsoft.com/Forums/en-US/20dbadae-dcee-406a-b66f-a182d76cea3b/troubleshooting-and-common-issues-guide?forum=kinectv2sdk


    Carmine Sirignano - MSFT

    Friday, April 3, 2015 5:21 PM
  • thank you very much for your answer.

    But I tried to execute the Windows BodyBasics D2D sample given with the SDK and everything works fine, so I'm sure my PC has no problems.

    Is there any initializations I missed or something?

    Tuesday, April 7, 2015 9:17 AM
  • Did you follow the pattern exactly? Did you release the frames when you were done?

    Carmine Sirignano - MSFT

    • Marked as answer by VulpesZerda Thursday, April 9, 2015 9:14 AM
    Wednesday, April 8, 2015 5:22 PM
  • I re-checked my program by comparison with the sample, and you are right, I forgot the release of the frames.

    I feel stupid now >_<

    Thank you very much for your help, it helped me and solved my problem.

    Here is the code that was missing at the end of the DetectBodies function.

    for (int i = 0; i < _countof(ppBodies); ++i)
    		{
    			if (ppBodies[i])
    			{
    				ppBodies[i]->Release();
    				ppBodies[i] = NULL;
    			}
    		}
    	}
    
    	if (pBodyFrame)
    	{
    		pBodyFrame->Release();
    		pBodyFrame = NULL;
    	}

    Thursday, April 9, 2015 9:14 AM