How do I track movement with KinectKit?
Last reviewed: 9/1/2012
HOW Article ID: H101208
The information in this article applies to:
- KinectKit
Summary
Tracking movement is the process of mapping movement from image and positional data captured by cameras.
Chant KinectKit is comprised of software components that handle the complexities of tracking movement with Microsoft Kinect sensors.
It simplifies the process of managing Kinect sensors with the Natural User Interface API (NAPI). You can process audio and visual data to map movement directly within software you develop and deploy.
Install Microsoft Kinect for Windows SDK and sensor and Chant KinectKit and you are ready to develop applications that track movement.
More Information
The KinectKit movement management component is designed to provide you a lot of flexiblity and minimize the programming necessary to manage the color, depth, skeleton, and audio data from a Microsoft Kinect sensor.
To start capturing data, simply use the Start method to turn on the sensor cameras. For example:
nChantKM.Start();
pChantKM->Start();
pChantKM->Start();
aTChantKM.Start();
jChantKM.start(nSensorID, eChantKinectStream);
nChantKM.Start()
To stop capturing data, simply use the Stop method to turn off the sensor cameras. For example:
nChantKM.Stop();
pChantKM->Stop();
pChantKM->Stop();
aTChantKM.Stop();
jChantKM.stop();
nChantKM.Stop()
The Start method initiates the session with the Microsoft Kinect sensor and enables the color, depth, and skeleton data streams by default. To process the stream data, you need to use the RegisterCallback method and declare a routine to handle the callback when data is available.
// Turn on KSStatusChanged events
NChantKM1.RegisterCallback(ChantCallback.CCKSStatusChanged);
private void NChantKM1_HasEvent(object sender, Chant.KinectKit.HasEventArgs e)
{
// Get the number of events
int numberOfEvents = NChantKM1.GetResourceCount(ChantSpeechResource.CSREvent, 0, 0);
for (int i = 0; i < numberOfEvents; i++)
{
// Get the event from the event queue
NChantKMEvent nChantKMEvent = NChantKM1.GetChantKMEvent(0);
switch (nChantKMEvent.ChantCallback)
{
case ChantCallback.CCKSStatusChanged:
...
break;
...
default:
break;
}
// Remove the event from the event queue
NChantKM1.RemoveResource(ChantSpeechResource.CSREvent, 0);
}
}
// Turn on KSStatusChanged events
pChantKM->RegisterCallback(CCKSStatusChanged);
LRESULT CCompileDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (m_pChantKM != NULL)
{
if (message == m_HasEvent)
{
CString sResult;
// Get the number of events
int numberOfEvents = m_pChantKM->GetResourceCount(CSREvent);
for (int i = 0; i < numberOfEvents; i++)
{
// Get the event from the event queue
CChantKMEvent* pChantKMEvent = m_pChantKM->GetChantKMEvent(0);
if (pChantKMEvent != NULL)
{
// Process the type of callback event
switch (pChantKMEvent->GetChantCallback())
{
case CCKSStatusChanged :
...
break;
...
default :
break;
}
// Remove the event from the event queue
m_pChantKM->RemoveResource(CSREvent, 0);
// Delete the C++ wrapper class object
delete pChantKMEvent;
pChantKMEvent = NULL;
}
}
}
}
return CDialog::DefWindowProc(message, wParam, lParam);
}
// Turn on KSStatusChanged events
pChantKM->RegisterCallback(CCKSStatusChanged);
void __fastcall TForm1::OnHasEvent(TMessage& msg)
{
// Get the number of events
int numberOfEvents = m_pChantKM->GetResourceCount(CSREvent);
for (int i = 0; i < numberOfEvents; i++)
{
// Get the event from the event queue
CChantKMEvent* pChantKMEvent = m_pChantKM->GetChantKMEvent(0);
if (pChantKMEvent != NULL)
{
// Process the type of callback event
switch (pChantKMEvent->GetChantCallback())
{
case CCKSStatusChanged :
...
break;
...
default :
break;
}
// Remove the event from the event queue
m_pChantKM->RemoveResource(CSREvent, 0);
// Dispose of the event object
delete pChantKMEvent;
pChantKMEvent = NULL;
}
}
}
// Turn on KSStatusChanged events
ChantKM1.RegisterCallback(CCKSStatusChanged);
procedure TForm1.OnHasEvent(var msg: TMessage);
var
tEvent: TChantKMEvent;
numberOfEvents: Integer;
i: Integer;
begin
numberOfEvents := ChantKM1.GetResourceCount(CSREvent,0,0);
for i := 0 to numberOfEvents - 1 do
begin
// Get the event from the event queue
tEvent := ChantKM1.GetChantKMEvent(0);
case tEvent.ChantCallback of
CCKSStatusChanged:
begin
...
end;
...
end;
// Remove the event from the event queue
ChantKM1.RemoveResource(CSREvent);
tEvent.Destroy();
end;
end;
// Turn on KSStatusChanged events
JChantKM1.registerCallback(ChantCallback.CCKSStatusChanged);
public void hasEvent(Object obj1, Object obj2)
{
// Get the event
JChantKMEvent jChantKMEvent = JChantKM1.getChantKMEvent(0);
// Process the type of callback event
if (jChantKMEvent != null)
{
switch(jChantKMEvent.getChantCallback())
{
case ChantCallback.CCKSStatusChanged:
...
break;
...
default:
break;
}
}
// Remove the event from the event queue
JChantKM1.removeResource(ChantSpeechResource.CSREvent, 0);
}
// Turn on KSStatusChanged events
NChantKM1.RegisterCallback(ChantCallback.CCKSStatusChanged)
Private Sub NChantKM1_HasEvent(ByVal sender As System.Object, ByVal e As Chant.KinectKit.HasEventArgs) Handles NChantKM1.HasEvent
Dim I As Integer
Dim numberOfEvents As Integer
Dim nChantKMEvent As NChantKMEvent
' Get the number of events
numberOfEvents = NChantKM1.GetResourceCount(ChantSpeechResource.CSREvent, 0, 0)
For I = 0 To numberOfEvents - 1
' Get the event from the event queue
nChantKMEvent = NChantKM1.GetChantKMEvent(0)
Select Case nChantKMEvent.ChantCallback
Case ChantCallback.CCKSStatusChanged
...
End Select
' Remove the event from the event queue
NChantKM1.RemoveResource(ChantSpeechResource.CSREvent, 0)
Next
End Sub
For additional help with KinectKit, contact Chant Support via or web.